Commit Graph

179350 Commits

Author SHA1 Message Date
GCC Administrator
50a71cd018 Daily bump. 2020-09-15 00:16:37 +00:00
Sergei Trofimovich
0620f4d79e doc: fix spelling of -fprofile-reproducibility
gcc/ChangeLog:

	* doc/invoke.texi: fix '-fprofile-reproducibility' option
	spelling in manual.
2020-09-14 23:31:34 +01:00
Ian Lance Taylor
05f40bc4c1 libbacktrace: support MiniDebugInfo
libbacktrace/ChangeLog:
	PR libbacktrace/93608
	Add support for MiniDebugInfo.
	* elf.c (struct elf_view): Define.  Replace most uses of
	backtrace_view with elf_view.
	(elf_get_view): New static functions.  Replace most calls of
	backtrace_get_view with elf_get_view.
	(elf_release_view): New static functions.  Replace most calls of
	backtrace_release_view with elf_release_view.
	(elf_uncompress_failed): Rename from elf_zlib_failed.  Change all
	callers.
	(LZMA_STATES, LZMA_POS_STATES, LZMA_DIST_STATES): Define.
	(LZMA_DIST_SLOTS, LZMA_DIST_MODEL_START): Define.
	(LZMA_DIST_MODEL_END, LZMA_FULL_DISTANCES): Define.
	(LZMA_ALIGN_SIZE, LZMA_LEN_LOW_SYMBOLS): Define.
	(LZMA_LEN_MID_SYMBOLS, LZMA_LEN_HIGH_SYMBOLS): Define.
	(LZMA_LITERAL_CODERS_MAX, LZMA_LITERAL_CODER_SIZE): Define.
	(LZMA_PROB_IS_MATCH_LEN, LZMA_PROB_IS_REP_LEN): Define.
	(LZMA_PROB_IS_REP0_LEN, LZMA_PROB_IS_REP1_LEN): Define.
	(LZMA_PROB_IS_REP2_LEN, LZMA_PROB_IS_REP0_LONG_LEN): Define.
	(LZMA_PROB_DIST_SLOT_LEN, LZMA_PROB_DIST_SPECIAL_LEN): Define.
	(LZMA_PROB_DIST_ALIGN_LEN): Define.
	(LZMA_PROB_MATCH_LEN_CHOICE_LEN): Define.
	(LZMA_PROB_MATCH_LEN_CHOICE2_LEN): Define.
	(LZMA_PROB_MATCH_LEN_LOW_LEN): Define.
	(LZMA_PROB_MATCH_LEN_MID_LEN): Define.
	(LZMA_PROB_MATCH_LEN_HIGH_LEN): Define.
	(LZMA_PROB_REP_LEN_CHOICE_LEN): Define.
	(LZMA_PROB_REP_LEN_CHOICE2_LEN): Define.
	(LZMA_PROB_REP_LEN_LOW_LEN): Define.
	(LZMA_PROB_REP_LEN_MID_LEN): Define.
	(LZMA_PROB_REP_LEN_HIGH_LEN): Define.
	(LZMA_PROB_LITERAL_LEN): Define.
	(LZMA_PROB_IS_MATCH_OFFSET, LZMA_PROB_IS_REP_OFFSET): Define.
	(LZMA_PROB_IS_REP0_OFFSET, LZMA_PROB_IS_REP1_OFFSET): Define.
	(LZMA_PROB_IS_REP2_OFFSET): Define.
	(LZMA_PROB_IS_REP0_LONG_OFFSET): Define.
	(LZMA_PROB_DIST_SLOT_OFFSET): Define.
	(LZMA_PROB_DIST_SPECIAL_OFFSET): Define.
	(LZMA_PROB_DIST_ALIGN_OFFSET): Define.
	(LZMA_PROB_MATCH_LEN_CHOICE_OFFSET): Define.
	(LZMA_PROB_MATCH_LEN_CHOICE2_OFFSET): Define.
	(LZMA_PROB_MATCH_LEN_LOW_OFFSET): Define.
	(LZMA_PROB_MATCH_LEN_MID_OFFSET): Define.
	(LZMA_PROB_MATCH_LEN_HIGH_OFFSET): Define.
	(LZMA_PROB_REP_LEN_CHOICE_OFFSET): Define.
	(LZMA_PROB_REP_LEN_CHOICE2_OFFSET): Define.
	(LZMA_PROB_REP_LEN_LOW_OFFSET): Define.
	(LZMA_PROB_REP_LEN_MID_OFFSET): Define.
	(LZMA_PROB_REP_LEN_HIGH_OFFSET): Define.
	(LZMA_PROB_LITERAL_OFFSET): Define.
	(LZMA_PROB_TOTAL_COUNT): Define.
	(LZMA_IS_MATCH, LZMA_IS_REP, LZMA_IS_REP0): Define.
	(LZMA_IS_REP1, LZMA_IS_REP2, LZMA_IS_REP0_LONG): Define.
	(LZMA_DIST_SLOT, LZMA_DIST_SPECIAL, LZMA_DIST_ALIGN): Define.
	(LZMA_MATCH_LEN_CHOICE, LZMA_MATCH_LEN_CHOICE2): Define.
	(LZMA_MATCH_LEN_LOW, LZMA_MATCH_LEN_MID): Define.
	(LZMA_MATCH_LEN_HIGH, LZMA_REP_LEN_CHOICE): Define.
	(LZMA_REP_LEN_CHOICE2, LZMA_REP_LEN_LOW): Define.
	(LZMA_REP_LEN_MID, LZMA_REP_LEN_HIGH, LZMA_LITERAL): Define.
	(elf_lzma_varint): New static function.
	(elf_lzma_range_normalize): New static function.
	(elf_lzma_bit, elf_lzma_integer): New static functions.
	(elf_lzma_reverse_integer): New static function.
	(elf_lzma_len, elf_uncompress_lzma_block): New static functions.
	(elf_uncompress_lzma): New static function.
	(backtrace_uncompress_lzma): New function.
	(elf_add): Add memory and memory_size parameters.  Change all
	callers.  Look for .gnu_debugdata section, and, if found,
	decompress it and use it for symbols and debug info.  Permit the
	descriptor parameter to be -1.
	* internal.h (backtrace_uncompress_lzma): Declare.
	* mtest.c: New file.
	* xztest.c: New file.
	* configure.ac: Check for nm, xz, and comm programs.  Check for
	liblzma library.
	(HAVE_MINIDEBUG): Define.
	* Makefile.am (mtest_SOURCES): Define.
	(mtest_CFLAGS, mtest_LDADD): Define.
	(TESTS): Add mtest_minidebug if HAVE_MINIDEBUG.
	(%_minidebug): New pattern rule, if HAVE_MINIDEBUG.
	(xztest_SOURCES, xztest_CFLAGS, xztest_LDADD): Define.
	(xztest_alloc_SOURCES, xztest_alloc_CFLAGS): Define
	(xztest_alloc_LDADD): Define.
	(BUILDTESTS): Add mtest, xztest, xztest_alloc.
	(CLEANFILES): Add files created by minidebug pattern.
	(btest.lo): Correct INCDIR reference.
	(mtest.lo, xztest.lo, ztest.lo): New targets.
	* configure: Regenerate.
	* config.h.in: Regenerate.
	* Makefile.in: Regenerate.
2020-09-14 14:11:17 -07:00
Marek Polacek
cd6743e9c4 c++: Use VAR_OR_FUNCTION_DECL_P.
gcc/cp/ChangeLog:

	* pt.c (push_template_decl_real): Use VAR_OR_FUNCTION_DECL_P.
2020-09-14 15:00:42 -04:00
Jose E. Marchesi
5bcc0fa05e bpf: use the expected instruction for NOPs
The BPF ISA doesn't have a no-operation instruction, but in practice
the Linux kernel verifier performs some optimizations that rely on
these instructions to be encoded in a particular way.  As it turns
out, we were using the "wrong" instruction in GCC.

This patch makes GCC to generate the expected instruction for NOP (a
`ja 0') and also adds a test to make sure this is the case.

Tested in bpf-unknown-none targets.

2020-09-14  Jose E. Marchesi  <jose.marchesi@oracle.com>

gcc/

	* config/bpf/bpf.md ("nop"): Re-define as `ja 0'.

gcc/testsuite/

	* gcc.target/bpf/nop-1.c: New test.
2020-09-14 20:55:13 +02:00
Iain Sandoe
0a3e6e975a Darwin, X86, testsuite: Fix pr87767 tests for Darwin.
The tests assume non-PIC for m32 (which means that they fail on default
PIC targets, like Darwin).  There is also a missing space before the
closing '}' on one of the dg-require-effective-target which means that
test fails on machines without avx512f.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/avx512f-broadcast-pr87767-1.c: Make the test
	run as non-dynamic for m32 Darwin.
	* gcc.target/i386/avx512f-broadcast-pr87767-3.c: Likewise.
	* gcc.target/i386/avx512f-broadcast-pr87767-5.c: Likewise.
	* gcc.target/i386/avx512f-broadcast-pr87767-7.c: Likewise.
	* gcc.target/i386/avx512vl-broadcast-pr87767-1.c: Likewise.
	* gcc.target/i386/avx512vl-broadcast-pr87767-3.c: Likewise.
	* gcc.target/i386/avx512vl-broadcast-pr87767-5.c: Likewise.
	* gcc.target/i386/avx512f-broadcast-pr87767-6.c: Adjust dg-requires
	clause.
2020-09-14 19:45:35 +01:00
Nathan Sidwell
e9fdb9a732 c++: local externs in templates do not get template head
Now we consistently mark local externs with DECL_LOCAL_DECL_P, we can
teach the template machinery not to give them a TEMPLATE_DECL head,
and the instantiation machinery treat them as the local specialiations
they are.  (openmp UDRs also fall into this category, and are dealt
with similarly.)

	gcc/cp/
	* pt.c (push_template_decl_real): Don't attach a template head to
	local externs.
	(tsubst_function_decl): Add support for headless local extern
	decls.
	(tsubst_decl): Add support for headless local extern decls.
2020-09-14 09:45:24 -07:00
David Malcolm
05ab8befe1 analyzer: add -param=analyzer-max-constraints=
On attempting to run the full test suite with -fanalyzer via
  make check RUNTESTFLAGS="-v -v --target_board=unix/-fanalyzer"
I saw it get stuck on:
  gcc.c-torture/compile/20001226-1.c
It turns out this was on a debug build, rather than a release build;
but a release build with -fanalyzer took:
  real 1m33.689s
  user 1m30.239s
  sys  0m2.727s
as compared to:
  real 0m2.361s
  user 0m2.107s
  sys  0m0.214s
without -fanalyzer.

This torture test performs 64 * 64 uniqely-coded comparisons between
elements of a pair of arrays until it finds an element that's different,
leading to an accumulation of 4096 constraints along the path where
no difference is found.

"perf" shows most of the time is spent in canonicalizing and copying
constraint_manager instances, presumably as it copies and merges states
with increasingly more complex sets of constraints as it analyzes
further along the "no differences yet" path.

This patch crudely works around this by adding a
  -param=analyzer-max-constraints=
limit, defaulting to 20, above which constraints will be silently
dropped.  With this -fanalyzer takes:
  real 0m6.935s
  user 0m6.413s
  sys  0m0.396s
on the above case.

gcc/analyzer/ChangeLog:
	* analyzer.opt (-param=analyzer-max-constraints=): New param.
	* constraint-manager.cc
	(constraint_manager::add_constraint_internal): Silently reject
	attempts to add constraints when the above limit is reached.
2020-09-14 12:29:35 -04:00
David Malcolm
799dd4e100 analyzer: fix constraint explosion on many-cased switch [PR96653]
PR analyzer/96653 reports a CPU-time and memory explosion in -fanalyzer
seen in Linux 5.9-rc1:drivers/media/v4l2-core/v4l2-ctrls.c on a switch
statement with many cases.

The issue is some old code in constraint_manager::get_or_add_equiv_class
for ensuring that comparisons between equivalence classes containing
constants work correctly.  The old code added constraints for every
pair of ECs containing constants, leading to O(N^2) constraints (for
N constants).  Given that get_or_add_equiv_class also involves O(N)
comparisons, this led to at least O(N^3) CPU time, and O(N^2) memory
consumption when handling the "default" case, where N is the number of
other cases in the switch statement.

The state rewrite of r11-2694-g808f4dfeb3a95f50f15e71148e5c1067f90a126d
added checking for comparisons between constants, making these explicit
constraints redundant, but failed to remove the code mentioned above.

This patch removes it, fixing the blow-up of constraints in the default
case.

gcc/analyzer/ChangeLog:
	PR analyzer/96653
	* constraint-manager.cc
	(constraint_manager::get_or_add_equiv_class): Don't accumulate
	transitive closure of all constraints on constants.

gcc/testsuite/ChangeLog:
	PR analyzer/96653
	* gcc.dg/analyzer/pr96653.c: New test.
2020-09-14 12:28:21 -04:00
David Malcolm
00adddd656 analyzer: add regression test for leak false positive
Downstream bug report:
  https://bugzilla.redhat.com/show_bug.cgi?id=1878600
describes a false positive from -Wanalyzer-file-leak seen with
gcc 10.2, but which has been fixed in gcc 11.

This patch adds the reproducer as a regression test.

gcc/testsuite/ChangeLog:
	* gcc.dg/analyzer/rhbz1878600.c: New test.
2020-09-14 12:27:28 -04:00
David Malcolm
35e3f0829d analyzer: fix ICE on setjmp with non-pointer-type [PR97029]
gcc/analyzer/ChangeLog:
	PR analyzer/97029
	* analyzer.cc (is_setjmp_call_p): Require the initial arg to be a
	pointer.
	* region-model.cc (region_model::deref_rvalue): Assert that the
	svalue is of pointer type.

gcc/testsuite/ChangeLog:
	* gcc.dg/analyzer/pr97029.c: New test.
2020-09-14 12:26:24 -04:00
Eric Botcazou
a7d8dcdf2f Fix dangling references in thunks at -O0
When a thunk cannot be emitted in assembly directly, expand_thunk
generates regular GIMPLE code but unconditionally forces a tail
call to the target of the thunk.  That's theoretically OK because
the thunk essentially forwards its parameters to the target, but
in practice the RTL expander can spill parameters passed by reference
on the stack in assign_parm_setup_reg.

gcc/ChangeLog:
	* cgraphunit.c (cgraph_node::expand_thunk): Make sure to set
	cfun->tail_call_marked when forcing a tail call.
	* function.c (assign_parm_setup_reg): Always use a register to
	load a parameter passed by reference if cfun->tail_call_marked.

gcc/testsuite/ChangeLog:
	* gnat.dg/thunk1.adb: New test.
	* gnat.dg/thunk1_pkg1.ads: New helper.
	* gnat.dg/thunk1_pkg2.ads: Likewise.
	* gnat.dg/thunk1_pkg2.adb: Likewise.
2020-09-14 17:38:39 +02:00
Pat Haugen
863e8d53eb Rename mffgpr/mftgpr insn types and remove Power6 references.
The following is mostly a mechanical change to rename the mffgpr/mftgpr
insn types to mtvsr/mfvsr to be more clear. It also removes Power6
references to those insn types since we no longer generate those
instructions.

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

gcc/
	* config/rs6000/power10.md (power10-mffgpr, power10-mftgpr): Rename to
	power10-mtvsr/power10-mfvsr.
	* config/rs6000/power6.md (X2F_power6, power6-mftgpr, power6-mffgpr):
	Remove.
	* config/rs6000/power8.md (power8-mffgpr, power8-mftgpr): Rename to
	power8-mtvsr/power8-mfvsr.
	* config/rs6000/power9.md (power9-mffgpr, power9-mftgpr): Rename to
	power9-mtvsr/power9-mfvsr.
	* config/rs6000/rs6000.c (rs6000_adjust_cost): Remove Power6
	TYPE_MFFGPR cases.
	* config/rs6000/rs6000.md (mffgpr, mftgpr, zero_extendsi<mode>2,
	extendsi<mode>2, @signbit<mode>2_dm, lfiwax, lfiwzx, *movsi_internal1,
	movsi_from_sf, *movdi_from_sf_zero_ext, *mov<mode>_internal,
	movsd_hardfloat, movsf_from_si, *mov<mode>_hardfloat64, p8_mtvsrwz,
	p8_mtvsrd_df, p8_mtvsrd_sf, p8_mfvsrd_3_<mode>, *movdi_internal64,
	unpack<mode>_dm): Rename mffgpr/mftgpr to mtvsr/mfvsr.
	* config/rs6000/vsx.md (vsx_mov<mode>_64bit, vsx_extract_<mode>,
	vsx_extract_si, *vsx_extract_<mode>_p8): Likewise.
2020-09-14 09:37:34 -05:00
Jakub Jelinek
d106029c2a arm: Fix up gcc.target/arm/lto/pr96939_* FAIL
The following patch on top of the
https://gcc.gnu.org/pipermail/gcc-patches/2020-September/553801.html
patch fixes the gcc.target/arm/lto/pr96939_* test in certain ARM
configurations.
As said in the above mentioned patch, the generic code takes care of
saving/restoring TargetVariables or Target Save options, so this just
arranges for the generic code to save those instead of needing the
arm backend to do it manually.

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

	* config/arm/arm.opt (x_arm_arch_string, x_arm_cpu_string,
	x_arm_tune_string): Remove TargetSave entries.
	(march=, mcpu=, mtune=): Add Save keyword.
	* config/arm/arm.c (arm_option_save): Remove.
	(TARGET_OPTION_SAVE): Don't redefine.
	(arm_option_restore): Don't restore x_arm_*_string here.
2020-09-14 10:53:50 +02:00
Andrea Corallo
02321f62f8 libgccjit: Regenerate documentation for new entry point.
Fix missing doc regeneration that should have been done by
4ecc0061c4 "libgccjit: Add new gcc_jit_global_set_initializer entry
point"
<https://gcc.gnu.org/onlinedocs/jit/internals/index.html#submitting-patches>.

gcc/jit/ChangeLog

2020-09-14  Andrea Corallo  <andrea.corallo@arm.com>

	* docs/_build/texinfo/libgccjit.texi: Regenerate.
2020-09-14 09:20:07 +02:00
Jakub Jelinek
ba948b3776 options: Save and restore opts_set for Optimization and Target options
> Seems a latent issue.
> Neither cl_optimization_{save,restore} nor cl_target_option_{save,restore}
> (nor any of the target hooks they call) saves or restores any opts_set
> values, so I think opts_set can be trusted only during option processing (if
> at all), but not later.
> So, short term a fix would be IMHO just stop using opts_set altogether in
> arm_configure_build_target, it doesn't make much sense to me, it should test
> if those strings are non-NULL instead, or at least do that when it is
> invoked from arm_option_restore (e.g. could be done by calling it with
> opts instead of &global_options_set ).
> Longer term, the question is if cl_optimization_{save,restore} and
> cl_target_option_{save,restore} shouldn't be changed not to only
> save/restore the options, but also save the opts_set flags.
> It could be done e.g. by adding a bool array or set of bool members
> to struct cl_optimization and struct cl_target_option , or even more compact
> by using bitmasks, pack each 64 adjacent option flags into a UHWI element
> of an array.

So, I've tried under debugger how it behaves and seems global_options_set
is really an or of whether an option has been ever seen as explicit, either
on the command line or in any of the option pragmas or optimize/target
attributes seen so far, so it isn't something that can be relied on.

The following patch implements the saving/restoring of the opts_set bits
(though only for the options/variables saved by the generic options-save.c
code, for the target specific stuff that isn't handled by the generic code
the opts_set argument is now passed to the hook and the backends can choose
e.g. to use a TargetSave variable to save the flags either individually or
together in some bitmask (or ignore it if they never need opts_set for the
options).

This patch itself doesn't fix the testcase failing on arm, but a follow up
patch will.

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

gcc/
	* opt-read.awk: Also initialize extra_target_var_types array.
	* opth-gen.awk: Emit explicit_mask arrays to struct cl_optimization
	and cl_target_option.  Adjust cl_optimization_save,
	cl_optimization_restore, cl_target_option_save and
	cl_target_option_restore declarations.
	* optc-save-gen.awk: Add opts_set argument to cl_optimization_save,
	cl_optimization_restore, cl_target_option_save and
	cl_target_option_restore functions and save or restore opts_set
	next to the opts values into or from explicit_mask arrays.
	In cl_target_option_eq and cl_optimization_option_eq compare
	explicit_mask arrays, in cl_target_option_hash and cl_optimization_hash
	hash them and in cl_target_option_stream_out,
	cl_target_option_stream_in, cl_optimization_stream_out and
	cl_optimization_stream_in stream them.
	* tree.h (build_optimization_node, build_target_option_node): Add
	opts_set argument.
	* tree.c (build_optimization_node): Add opts_set argument, pass it
	to cl_optimization_save.
	(build_target_option_node): Add opts_set argument, pass it to
	cl_target_option_save.
	* function.c (invoke_set_current_function_hook): Adjust
	cl_optimization_restore caller.
	* ipa-inline-transform.c (inline_call): Adjust cl_optimization_restore
	and build_optimization_node callers.
	* target.def (TARGET_OPTION_SAVE, TARGET_OPTION_RESTORE): Add opts_set
	argument.
	* target-globals.c (save_target_globals_default_opts): Adjust
	cl_optimization_restore callers.
	* toplev.c (process_options): Adjust build_optimization_node and
	cl_optimization_restore callers.
	(target_reinit): Adjust cl_optimization_restore caller.
	* tree-streamer-in.c (lto_input_ts_function_decl_tree_pointers):
	Adjust build_optimization_node and cl_optimization_restore callers.
	* doc/tm.texi: Updated.
	* config/aarch64/aarch64.c (aarch64_override_options): Adjust
	build_target_option_node caller.
	(aarch64_option_save, aarch64_option_restore): Add opts_set argument.
	(aarch64_set_current_function): Adjust cl_target_option_restore
	caller.
	(aarch64_option_valid_attribute_p): Adjust cl_target_option_save,
	cl_target_option_restore, cl_optimization_restore,
	build_optimization_node and build_target_option_node callers.
	* config/aarch64/aarch64-c.c (aarch64_pragma_target_parse): Adjust
	cl_target_option_restore and build_target_option_node callers.
	* config/arm/arm.c (arm_option_save, arm_option_restore): Add
	opts_set argument.
	(arm_option_override): Adjust cl_target_option_save,
	build_optimization_node and build_target_option_node callers.
	(arm_set_current_function): Adjust cl_target_option_restore caller.
	(arm_valid_target_attribute_tree): Adjust build_target_option_node
	caller.
	(add_attribute): Formatting fix.
	(arm_valid_target_attribute_p): Adjust cl_optimization_restore,
	cl_target_option_restore, arm_valid_target_attribute_tree and
	build_optimization_node callers.
	* config/arm/arm-c.c (arm_pragma_target_parse): Adjust
	cl_target_option_restore callers.
	* config/csky/csky.c (csky_option_override): Adjust
	build_target_option_node and cl_target_option_save callers.
	* config/gcn/gcn.c (gcn_fixup_accel_lto_options): Adjust
	build_optimization_node and cl_optimization_restore callers.
	* config/i386/i386-builtins.c (get_builtin_code_for_version):
	Adjust cl_target_option_save and cl_target_option_restore
	callers.
	* config/i386/i386-c.c (ix86_pragma_target_parse): Adjust
	build_target_option_node and cl_target_option_restore callers.
	* config/i386/i386-options.c (ix86_function_specific_save,
	ix86_function_specific_restore): Add opts_set arguments.
	(ix86_valid_target_attribute_tree): Adjust build_target_option_node
	caller.
	(ix86_valid_target_attribute_p): Adjust build_optimization_node,
	cl_optimization_restore, cl_target_option_restore,
	ix86_valid_target_attribute_tree and build_optimization_node callers.
	(ix86_option_override_internal): Adjust build_target_option_node
	caller.
	(ix86_reset_previous_fndecl, ix86_set_current_function): Adjust
	cl_target_option_restore callers.
	* config/i386/i386-options.h (ix86_function_specific_save,
	ix86_function_specific_restore): Add opts_set argument.
	* config/nios2/nios2.c (nios2_option_override): Adjust
	build_target_option_node caller.
	(nios2_option_save, nios2_option_restore): Add opts_set argument.
	(nios2_valid_target_attribute_tree): Adjust build_target_option_node
	caller.
	(nios2_valid_target_attribute_p): Adjust build_optimization_node,
	cl_optimization_restore, cl_target_option_save and
	cl_target_option_restore callers.
	(nios2_set_current_function, nios2_pragma_target_parse): Adjust
	cl_target_option_restore callers.
	* config/pru/pru.c (pru_option_override): Adjust
	build_target_option_node caller.
	(pru_set_current_function): Adjust cl_target_option_restore
	callers.
	* config/rs6000/rs6000.c (rs6000_debug_reg_global): Adjust
	cl_target_option_save caller.
	(rs6000_option_override_internal): Adjust build_target_option_node
	caller.
	(rs6000_valid_attribute_p): Adjust build_optimization_node,
	cl_optimization_restore, cl_target_option_save,
	cl_target_option_restore and build_target_option_node callers.
	(rs6000_pragma_target_parse): Adjust cl_target_option_restore and
	build_target_option_node callers.
	(rs6000_activate_target_options): Adjust cl_target_option_restore
	callers.
	(rs6000_function_specific_save, rs6000_function_specific_restore):
	Add opts_set argument.
	* config/s390/s390.c (s390_function_specific_restore): Likewise.
	(s390_option_override_internal): Adjust s390_function_specific_restore
	caller.
	(s390_option_override, s390_valid_target_attribute_tree): Adjust
	build_target_option_node caller.
	(s390_valid_target_attribute_p): Adjust build_optimization_node,
	cl_optimization_restore and cl_target_option_restore callers.
	(s390_activate_target_options): Adjust cl_target_option_restore
	caller.
	* config/s390/s390-c.c (s390_cpu_cpp_builtins): Adjust
	cl_target_option_save caller.
	(s390_pragma_target_parse): Adjust build_target_option_node and
	cl_target_option_restore callers.
gcc/c-family/
	* c-attribs.c (handle_optimize_attribute): Adjust
	cl_optimization_save, cl_optimization_restore and
	build_optimization_node callers.
	* c-pragma.c (handle_pragma_optimize): Adjust
	build_optimization_node caller.
	(handle_pragma_push_options): Adjust
	build_optimization_node and build_target_option_node callers.
	(handle_pragma_pop_options, handle_pragma_reset_options):
	Adjust cl_optimization_restore callers.
gcc/go/
	* go-gcc.cc (Gcc_backend::function): Adjust
	cl_optimization_save, cl_optimization_restore and
	build_optimization_node callers.
gcc/ada/
	* gcc-interface/trans.c (gigi): Adjust build_optimization_node
	caller.
2020-09-14 09:04:45 +02:00
Tom de Vries
4ac7b66958 [libgomp, nvptx] Add __sync_compare_and_swap_16
As reported here
( https://gcc.gnu.org/pipermail/gcc-patches/2020-September/553070.html  ),
when running test-case libgomp.c-c++-common/reduction-16.c for powerpc host
with nvptx accelerator, we run into:
...
unresolved symbol __sync_val_compare_and_swap_16
...

I can reproduce the problem on x86_64 with a trigger patch that:
- initializes ix86_isa_flags2 to TARGET_ISA2_CX16
- enables define_expand "atomic_load<mode>" in gcc/config/i386/sync.md
  for TImode

The problem is that omp-expand.c generates atomic builtin calls based on
checks whether those are supported on the host, which forces the target to
support these, even though those checks fail for the accelerator target.

Fix this by:
- adding a __sync_val_compare_and_swap_16 in libgomp for nvptx,
  which falls back onto libatomic's __atomic_compare_and_swap_16
- adding -foffload=-latomic in the test-case

Tested libgomp on x86_64-linux with nvptx accelerator.

Tested libgomp with trigger patch on x86_64-linux with nvptx accelerator.

libgomp/ChangeLog:

	* config/nvptx/atomic.c: New file.  Add
	__sync_val_compare_and_swap_16.
	* testsuite/libgomp.c-c++-common/reduction-16.c: Add -latomic for
	target offload_target_nvptx.
2020-09-14 08:28:56 +02:00
GCC Administrator
919858077f Daily bump. 2020-09-14 00:16:23 +00:00
John David Anglin
2fd157813c Improve costs for DImode shifts of interger constants.
2020-09-13  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
	* config/pa/pa.c (hppa_rtx_costs) [ASHIFT, ASHIFTRT, LSHIFTRT]:
	Provide accurate costs for DImode shifts of integer constants.
2020-09-13 18:47:59 +00:00
GCC Administrator
5de41c8862 Daily bump. 2020-09-13 00:16:23 +00:00
Iain Buclaw
707e9159ed d: Return promoted types in d_type_promotes_to when linkage is not D
This enables warnings to be shown when a bad type is passed to va_arg
inside an extern(C) or extern(C++) function.

gcc/d/ChangeLog:

	PR d/97002
	* d-codegen.cc (d_build_call): Set input_location on CALL_EXPR.
	* d-lang.cc: Include function.h.
	(d_type_promotes_to): Do default conversions for C and C++ functions.
	* intrinsics.cc (expand_intrinsic_vaarg): Use build1_loc to build
	VA_ARG_EXPR.

gcc/testsuite/ChangeLog:

	PR d/97002
	* gdc.dg/pr97002.d: New test.
2020-09-12 21:34:38 +02:00
Iain Buclaw
e4011c13c1 d: Build TYPE_DECLs for non-numeric enum types.
This is done so that the DWARF pass will emit a DW_TAG_typedef where the
member type of an enum can't be represented in an ENUMERAL_TYPE.

gcc/d/ChangeLog:

	* d-builtins.cc (d_build_d_type_nodes): Call build_ctype() on all
	basic front-end types.
	* decl.cc (DeclVisitor::visit (EnumDeclaration *)): Always add decl to
	current binding level.
	(build_type_decl): Build TYPE_DECL as a typedef if not for an enum or
	record type.
	* types.cc (TypeVisitor::visit (TypeEnum *)): Set underlying type for
	ENUMERAL_TYPEs.  Build TYPE_DECL for non-numeric enums.
2020-09-12 21:34:38 +02:00
John David Anglin
49482217e0 Add new shrpsi instruction variands to gcc/config/pa/pa.md.
2020-09-12  Roger Sayle  <roger@nextmovesoftware.com>
	    John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog
	* config/pa/pa.md (shrpsi4_1, shrpsi4_2): New define_insns split
	out from previous shrpsi4 providing two commutitive variants using
	plus_xor_ior_operator as a predicate.
	(shrpdi4_1, shrpdi4_2, shrpdi_3, shrpdi_4): Likewise DImode versions
	where _1 and _2 take register shifts, and _3 and _4 for integers.
	(rotlsi3_internal): Name this anonymous instruction.
	(rotrdi3): New DImode insn copied from rotrsi3.
	(rotldi3): New DImode expander copied from rotlsi3.
	(rotldi4_internal): New DImode insn copied from rotsi3_internal.
2020-09-12 14:43:27 +00:00
Eric Botcazou
f2d9f95e9c Add preliminary support for 128-bit integer types
This is only the gigi part, in preparation for the bulk of the
implementation.

gcc/ada/ChangeLog:
	* fe.h: Fix pilot error in previous change.
	* gcc-interface/gigi.h (enum standard_datatypes): Add ADT_mulv128_decl.
	(mulv128_decl): New macro.
	(get_target_long_long_long_size): Declare.
	* gcc-interface/decl.c (gnat_to_gnu_entity): Use a maximum size of
	128 bits for discrete types if Enable_128bit_Types is true.
	* gcc-interface/targtyps.c: Include target.h.
	(get_target_long_long_long_size): New function.
	* gcc-interface/trans.c (gigi): Initialize mulv128_decl if need be.
	(build_binary_op_trapv): Call it for 128-bit multiplication.
	* gcc-interface/utils.c (make_type_from_size): Enforce a maximum
	size of 128 bits if Enable_128bit_Types is true.
2020-09-12 13:01:19 +02:00
Eric Botcazou
fe47e81639 Fix small inconsistency in new predicate
This can result on the mainline in a segfault when an object declared
at library level is used in the declaration of another, local object.

gcc/ada/ChangeLog:
	* gcc-interface/trans.c (lvalue_for_aggr_p) <N_Object_Declaration>:
	Return false unconditionally.
2020-09-12 12:47:39 +02:00
Eric Botcazou
b440715089 Minor tweak to line debug info
This prevents the SLOC of the expression for a tag from being present
in the line debug info every time it is referenced for coverage purposes.

gcc/ada/ChangeLog:
	* gcc-interface/trans.c (gnat_to_gnu) <N_Object_Declaration>: Clear
	the SLOC of the expression of a tag.
2020-09-12 12:42:06 +02:00
Eric Botcazou
4965be0b33 Accept absolute address clause for array of UNC nominal subtype
This changes the compiler to accept again absolute address clause for
aliased array of unconstrained nominal subtype, instead of erroring
out in this case.

gcc/ada/ChangeLog:
	* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Only give
	a warning for the overlay of an aliased array with an unconstrained
	nominal subtype if the address is absolute.
2020-09-12 12:37:47 +02:00
GCC Administrator
ac35c09082 Daily bump. 2020-09-12 00:16:30 +00:00
Michael Meissner
e73f586c93 PowerPC: rename some functions.
gcc/
2020-09-11  Michael Meissner  <meissner@linux.ibm.com>

	* config/rs6000/rs6000.c (rs6000_maybe_emit_maxc_minc): Rename
	from rs6000_emit_p9_fp_minmax.  Change return type to bool.  Add
	comments to document NaN/signed zero behavior.
	(rs6000_maybe_emit_fp_cmove): Rename from rs6000_emit_p9_fp_cmove.
	(have_compare_and_set_mask): New helper function.
	(rs6000_emit_cmove): Update calls to new names and the new helper
	function.
2020-09-11 18:10:14 -04:00
Nathan Sidwell
9d377c280c i386: Fix array index in expander
I noticed a compiler warning about out-of-bound access.  Fixed thusly.

	gcc/
	* config/i386/sse.md (mov<mode>): Fix operand indices.
2020-09-11 14:19:04 -07:00
Thomas Rodgers
64064678d6 libstdc++: only pull in bits/align.h if C++11 or later
libstdc++-v3/ChangeLog:

	* include/std/memory: Move #include <bits/align.h> inside C++11
	conditional includes.
2020-09-11 14:08:13 -07:00
Nathan Sidwell
f76b0f231b c++: Concepts and local externs
I discovered that we'd accept constraints on block-scope function
decls inside templates.  This fixes that.

	gcc/cp/
	* decl.c (grokfndecl): Don't attach to local extern.
2020-09-11 13:55:45 -07:00
Will Schmidt
2fda9e9bad [PATCH,rs6000] Testsuite fixup pr96139 tests
Hi,
  As reported, the recently added pr96139 tests will fail on older targets
  because the tests are missing the appropriate -mvsx or -maltivec options.
  This adds the options and clarifies the dg-require statements.

  The pr96139-c.c test needs -maltivec to work, but does not actually use
  vectors, so does not require -mvsx like the others.

  Sniff-regtested OK when specifying older targets on a power7 host.
  --target_board=unix/'{-mcpu=power4,-mcpu=power5,-mcpu=power6,-mcpu=power7,
  -mcpu=power8,-mcpu=power9}''{-m64,-m32}'"


gcc/testsuite/ChangeLog:
	* gcc.target/powerpc/pr96139-a.c: Specify -mvsx option and update the
	dg-require stanza to match.
	* gcc.target/powerpc/pr96139-b.c: Same.
	* gcc.target/powerpc/pr96139-c.c: Specify -maltivec option and update
	the dg-require stanza to match.
2020-09-11 15:47:20 -05:00
Thomas Rodgers
2c3b1c5f95 libstdc++: Split std::align/assume_aligned to bits/align.h
We would like to be able to use std::align and std::assume_aligned
without pulling in everything in <memory>.

libstdc++-v3/ChangeLog:

	* include/Makefile.am (bits_headers): Add new header.
	* include/Makefile.in: Regenerate.
	* include/bits/align.h: New file.
	* include/std/memory (align): Move definition to bits/align.h.
	(assume_aligned): Likewise.
2020-09-11 13:13:12 -07:00
Jonathan Wakely
53ad6b1979 libstdc++: Fix chrono::__detail::ceil to work with C++11
In C++11 constexpr functions can only have a return statement, so we
need to fix __detail::ceil to make it valid in C++11. This can be done
by moving the comparison and increment into a new function, __ceil_impl,
and calling that with the result of the duration_cast.

This would mean the standard C++17 std::chrono::ceil function would make
two further calls, which would add too much overhead when not inlined.
For C++17 and later use a using-declaration to add chrono::ceil to
namespace __detail. For C++11 and C++14 define chrono::__detail::__ceil
as a C++11-compatible constexpr function template.

libstdc++-v3/ChangeLog:

	* include/std/chrono [C++17] (chrono::__detail::ceil): Add
	using declaration to make chrono::ceil available for internal
	use with a consistent name.
	(chrono::__detail::__ceil_impl): New function template.
	(chrono::__detail::ceil): Use __ceil_impl to compare and
	increment the value. Remove SFINAE constraint.
2020-09-11 19:59:11 +01:00
Sunil K Pandey
40e99ed5f4 Fix fma test case [PR97018]
These tests are written for 256 bit vector. For -march=cascadelake,
vector size changed to 512 bit. It doubles the number of fma
instruction and test fail. Fix is to explicitly disable 512 bit
vector by passing additional option -mno-avx512f.

Tested on x86-64.

gcc/testsuite/ChangeLog:

	PR target/97018
	* gcc.target/i386/l_fma_double_1.c: Add option -mno-avx512f.
	* gcc.target/i386/l_fma_double_2.c: Likewise.
	* gcc.target/i386/l_fma_double_3.c: Likewise.
	* gcc.target/i386/l_fma_double_4.c: Likewise.
	* gcc.target/i386/l_fma_double_5.c: Likewise.
	* gcc.target/i386/l_fma_double_6.c: Likewise.
	* gcc.target/i386/l_fma_float_1.c: Likewise.
	* gcc.target/i386/l_fma_float_2.c: Likewise.
	* gcc.target/i386/l_fma_float_3.c: Likewise.
	* gcc.target/i386/l_fma_float_4.c: Likewise.
	* gcc.target/i386/l_fma_float_5.c: Likewise.
	* gcc.target/i386/l_fma_float_6.c: Likewise.
2020-09-11 09:52:21 -07:00
Martin Sebor
f36a8168f0 Move/correct offset adjustment (PR middle-end/96903).
Resolves:
PR middle-end/96903 - bogus warning on memcpy at negative offset from array end

gcc/ChangeLog:

	PR middle-end/96903
	* builtins.c (compute_objsize): Remove incorrect offset adjustment.
	(compute_objsize): Adjust offset range here instead.

gcc/testsuite/ChangeLog:

	PR middle-end/96903
	* gcc.dg/Wstringop-overflow-42.c:: Add comment.
	* gcc.dg/Wstringop-overflow-43.c: New test.
2020-09-11 09:42:29 -06:00
Nathan Sidwell
1be7bf7dab objc++: Always pop scope with method definitions [PR97015]
Syntax errors in method definition lists could leave us in a function
scope.  My recent change for block scope externs didn't like that.
This reimplements the parsing loop to finish the method definition we
started.  AFAICT the original code was attempting to provide some
error recovery.  Also while there, simply do the token peeking at the
top of the loop, rather than at the two(!) ends.

	gcc/cp/
	* parser.c (cp_parser_objc_method_definition_list): Reimplement
	loop, make sure we pop scope.
	gcc/testsuite/
	* obj-c++.dg/syntax-error-9.mm: Adjust expected errors.
2020-09-11 08:27:40 -07:00
Marek Polacek
13144466f1 c++: Remove LOOKUP_CONSTINIT.
Since we now have DECL_DECLARED_CONSTINIT_P, we no longer need
LOOKUP_CONSTINIT.

gcc/cp/ChangeLog:

	* cp-tree.h (LOOKUP_CONSTINIT): Remove.
	(LOOKUP_REWRITTEN): Adjust.
	* decl.c (duplicate_decls): Set DECL_DECLARED_CONSTINIT_P.
	(check_initializer): Use DECL_DECLARED_CONSTINIT_P instead of
	LOOKUP_CONSTINIT.
	(cp_finish_decl): Don't set DECL_DECLARED_CONSTINIT_P.  Use
	DECL_DECLARED_CONSTINIT_P instead of LOOKUP_CONSTINIT.
	(grokdeclarator): Set DECL_DECLARED_CONSTINIT_P.
	* decl2.c (grokfield): Don't handle LOOKUP_CONSTINIT.
	* parser.c (cp_parser_decomposition_declaration): Remove
	LOOKUP_CONSTINIT handling.
	(cp_parser_init_declarator): Likewise.
	* pt.c (tsubst_expr): Likewise.
	(instantiate_decl): Likewise.
	* typeck2.c (store_init_value): Use DECL_DECLARED_CONSTINIT_P instead
	of LOOKUP_CONSTINIT.
2020-09-11 11:17:03 -04:00
Jonathan Wakely
29216f56d0 libstdc++: Fix build error in <bits/regex_error.h>
libstdc++-v3/ChangeLog:

	* include/bits/regex_error.h (__throw_regex_error): Fix
	parameter declaration and use reserved attribute names.
2020-09-11 14:52:40 +01:00
Mike Crowe
e05ff30078 libstdc++: Avoid rounding errors on custom clocks in condition_variable
The fix for PR68519 in 83fd5e73b3 only
applied to condition_variable::wait_for. This problem can also apply to
condition_variable::wait_until but only if the custom clock is using a
more recent epoch so that a small enough delta can be calculated. let's
use the newly-added chrono::__detail::ceil to fix this and also make use
of that function to simplify the previous wait_for fixes.

Also, simplify the existing test case for PR68519 a little and make its
variables local so we can add a new test case for the above problem.
Unfortunately, the test would have only started failing if sufficient
time has passed since the chrono::steady_clock epoch had passed anyway,
but it's better than nothing.

libstdc++-v3/ChangeLog:

	* include/std/condition_variable (condition_variable::wait_until):
	Convert delta to steady_clock duration before adding to current
	steady_clock time to avoid rounding errors described in PR68519.
	(condition_variable::wait_for): Simplify calculation of absolute
	time by using chrono::__detail::ceil in both overloads.
	* testsuite/30_threads/condition_variable/members/68519.cc:
	(test_wait_for): Renamed from test01. Replace unassigned val
	variable with constant false. Reduce scope of mx and cv
	variables to just test_wait_for function.
	(test_wait_until): Add new test case.
2020-09-11 14:28:50 +01:00
Mike Crowe
f9ddb696a2 libstdc++: Avoid rounding errors in std::future::wait_* [PR 91486]
Convert the specified duration to the target clock's duration type
before adding it to the current time in
__atomic_futex_unsigned::_M_load_when_equal_for and
_M_load_when_equal_until.  This removes the risk of the timeout being
rounded down to the current time resulting in there being no wait at all
when the duration type lacks sufficient precision to hold the
steady_clock current time.

Rather than using the style of fix from PR68519, let's expose the C++17
std::chrono::ceil function as std::chrono::__detail::ceil so that it can
be used in code compiled with earlier standards versions and simplify
the fix. This was suggested by John Salmon in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91486#c5 .

This problem has become considerably less likely to trigger since I
switched the __atomic__futex_unsigned::__clock_t reference clock from
system_clock to steady_clock and added the loop, but the consequences of
triggering it have changed too.

By my calculations it takes just over 194 days from the epoch for the
current time not to be representable in a float. This means that
system_clock is always subject to the problem (with the standard 1970
epoch) whereas steady_clock with float duration only runs out of
resolution machine has been running for that long (assuming the Linux
implementation of CLOCK_MONOTONIC.)

The recently-added loop in
__atomic_futex_unsigned::_M_load_when_equal_until turns this scenario
into a busy wait.

Unfortunately the combination of both of these things means that it's
not possible to write a test case for this occurring in
_M_load_when_equal_until as it stands.

libstdc++-v3/ChangeLog:

	PR libstdc++/91486
	* include/bits/atomic_futex.h
	(__atomic_futex_unsigned::_M_load_when_equal_for)
	(__atomic_futex_unsigned::_M_load_when_equal_until): Use
	__detail::ceil to convert delta to the reference clock
	duration type to avoid resolution problems.
	* include/std/chrono (__detail::ceil): Move implementation
	of std::chrono::ceil into private namespace so that it's
	available to pre-C++17 code.
	* testsuite/30_threads/async/async.cc (test_pr91486):
	Test __atomic_futex_unsigned::_M_load_when_equal_for.
2020-09-11 14:28:50 +01:00
Mike Crowe
b9faa3301c libstdc++: Loop when futex waits against arbitrary clock
If std::future::wait_until is passed a time point measured against a
clock that is neither std::chrono::steady_clock nor
std::chrono::system_clock then the generic implementation of
__atomic_futex_unsigned::_M_load_when_equal_until is called which
calculates the timeout based on __clock_t and calls the
_M_load_when_equal_until method for that clock to perform the actual
wait.

There's no guarantee that __clock_t is running at the same speed as the
caller's clock, so if the underlying wait times out timeout we need to
check the timeout against the caller's clock again before potentially
looping.

Also add two extra tests to the testsuite's async.cc:

* run test03 with steady_clock_copy, which behaves identically to
  chrono::steady_clock, but isn't chrono::steady_clock. This causes
  the overload of __atomic_futex_unsigned::_M_load_when_equal_until
  that takes an arbitrary clock to be called.

* invent test04 which uses a deliberately slow running clock in order
  to exercise the looping behaviour of
  __atomic_futex_unsigned::_M_load_when_equal_until described above.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_futex.h
	(__atomic_futex_unsigned::_M_load_when_equal_until): Add
	loop on generic _Clock to check the timeout against _Clock
	again after _M_load_when_equal_until returns indicating a
	timeout.
	* testsuite/30_threads/async/async.cc: Invent slow_clock
	that runs at an eleventh of steady_clock's speed. Use it
	to test the user-supplied-clock variant of
	__atomic_futex_unsigned::_M_load_when_equal_until works
	generally with test03 and loops correctly when the timeout
	time hasn't been reached in test04.
2020-09-11 14:28:50 +01:00
Mike Crowe
87fce1923f libstdc++: Use std::chrono::steady_clock as atomic_futex reference clock
The user-visible effect of this change is that std::future::wait_for now
uses std::chrono::steady_clock to determine the timeout.  This makes it
immune to changes made to the system clock.  It also means that anyone
using their own clock types with std::future::wait_until will have the
timeout converted to std::chrono::steady_clock rather than
std::chrono::system_clock.

Now that use of both std::chrono::steady_clock and
std::chrono::system_clock are correctly supported for the wait timeout, I
believe that std::chrono::steady_clock is a better choice for the reference
clock that all other clocks are converted to since it is guaranteed to
advance steadily.  The previous behaviour of converting to
std::chrono::system_clock risks timeouts changing dramatically when the
system clock is changed.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_futex.h (__atomic_futex_unsigned): Change
	__clock_t typedef to use steady_clock so that unknown clocks are
	synced to it rather than system_clock. Change existing __clock_t
	overloads of _M_load_and_text_until_impl and
	_M_load_when_equal_until to use system_clock explicitly. Remove
	comment about DR 887 since these changes address that problem as
	best as we currently able.
2020-09-11 14:28:24 +01:00
Mike Crowe
01d412ef36 libstdc++: Support futex waiting on chrono::steady_clock directly
The user-visible effect of this change is for std::future::wait_until to
use CLOCK_MONOTONIC when passed a timeout of std::chrono::steady_clock
type.  This makes it immune to any changes made to the system clock
CLOCK_REALTIME.

Add an overload of __atomic_futex_unsigned::_M_load_and_text_until_impl
that accepts a std::chrono::steady_clock, and correctly passes this
through to __atomic_futex_unsigned_base::_M_futex_wait_until_steady
which uses CLOCK_MONOTONIC for the timeout within the futex system call.
These functions are mostly just copies of the std::chrono::system_clock
versions with small tweaks.

Prior to this commit, a std::chrono::steady timeout would be converted
via std::chrono::system_clock which risks reducing or increasing the
timeout if someone changes CLOCK_REALTIME whilst the wait is happening.
(The commit immediately prior to this one increases the window of
opportunity for that from a short period during the calculation of a
relative timeout, to the entire duration of the wait.)

FUTEX_WAIT_BITSET was added in kernel v2.6.25.  If futex reports ENOSYS
to indicate that this operation is not supported then the code falls
back to using clock_gettime(2) to calculate a relative time to wait for.

I believe that I've added this functionality in a way that it doesn't
break ABI compatibility, but that has made it more verbose and less type
safe.  I believe that it would be better to maintain the timeout as an
instance of the correct clock type all the way down to a single
_M_futex_wait_until function with an overload for each clock.  The
current scheme of separating out the seconds and nanoseconds early risks
accidentally calling the wait function for the wrong clock.
Unfortunately, doing this would break code that compiled against the old
header.

libstdc++-v3/ChangeLog:

	* config/abi/pre/gnu.ver: Update for addition of
	__atomic_futex_unsigned_base::_M_futex_wait_until_steady.
	* include/bits/atomic_futex.h (__atomic_futex_unsigned_base):
	Add comments to clarify that _M_futex_wait_until and
	_M_load_and_test_until use CLOCK_REALTIME.
	(__atomic_futex_unsigned_base::_M_futex_wait_until_steady)
	(__atomic_futex_unsigned_base::_M_load_and_text_until_steady):
	New member functions that use CLOCK_MONOTONIC.
	(__atomic_futex_unsigned_base::_M_load_and_test_until_impl)
	(__atomic_futex_unsigned_base::_M_load_when_equal_until): Add
	overloads that accept a steady_clock time_point and use the
	new member functions.
	* src/c++11/futex.cc: Include headers required for
	clock_gettime.
	(futex_clock_monotonic_flag): New constant to tell futex to
	use CLOCK_MONOTONIC to match existing futex_clock_realtime_flag.
	(futex_clock_monotonic_unavailable): New global to store the
	result of trying to use CLOCK_MONOTONIC.
	(__atomic_futex_unsigned_base::_M_futex_wait_until_steady): Add
	new variant of _M_futex_wait_until that uses CLOCK_MONOTONIC to
	support waiting using steady_clock.
2020-09-11 14:25:00 +01:00
Mike Crowe
5bad23ceec libstdc++: Use FUTEX_CLOCK_REALTIME for futex wait
The futex system call supports waiting for an absolute time if
FUTEX_WAIT_BITSET is used rather than FUTEX_WAIT.  Doing so provides two
benefits:

1. The call to gettimeofday is not required in order to calculate a
   relative timeout.

2. If someone changes the system clock during the wait then the futex
   timeout will correctly expire earlier or later.  Currently that only
   happens if the clock is changed prior to the call to gettimeofday.

According to futex(2), support for FUTEX_CLOCK_REALTIME was added in the
v2.6.28 Linux kernel and FUTEX_WAIT_BITSET was added in v2.6.25.  To
ensure that the code still works correctly with earlier kernel versions,
an ENOSYS error from futex[1] results in the
futex_clock_realtime_unavailable flag being set.  This flag is used to
avoid the unnecessary unsupported futex call in the future and to fall
back to the previous gettimeofday and relative time implementation.

glibc applied an equivalent switch in pthread_cond_timedwait to use
FUTEX_CLOCK_REALTIME and FUTEX_WAIT_BITSET rather than FUTEX_WAIT for
glibc-2.10 back in 2009.  See
glibc:cbd8aeb836c8061c23a5e00419e0fb25a34abee7

The futex_clock_realtime_unavailable flag is accessed using
std::memory_order_relaxed to stop it becoming a bottleneck.  If the
first two calls to _M_futex_wait_until happen to happen simultaneously
then the only consequence is that both will try to use
FUTEX_CLOCK_REALTIME, both risk discovering that it doesn't work and, if
so, both set the flag.

[1] This is how glibc's nptl-init.c determines whether these flags are
    supported.

libstdc++-v3/ChangeLog:

	* src/c++11/futex.cc: Add new constants for required futex
	flags.  Add futex_clock_realtime_unavailable flag to store
	result of trying to use FUTEX_CLOCK_REALTIME.
	(__atomic_futex_unsigned_base::_M_futex_wait_until): Try to
	use FUTEX_WAIT_BITSET with FUTEX_CLOCK_REALTIME and only
	fall back to using gettimeofday and FUTEX_WAIT if that's not
	supported.
2020-09-11 14:24:59 +01:00
Mike Crowe
f639343dc8 libstdc++: Improve std::async test
Add tests for waiting for the future using both chrono::steady_clock and
chrono::system_clock in preparation for dealing with those clocks
properly in futex.cc.

libstdc++-v3/ChangeLog:

	* testsuite/30_threads/async/async.cc (test02): Test steady_clock
	with std::future::wait_until.
	(test03): Add new test templated on clock type waiting for future
	associated with async to resolve.
	(main): Call test03 to test both system_clock and steady_clock.
2020-09-11 14:24:59 +01:00
Christophe Lyon
55bdee9af3 libstdc++-v3/libsupc++/eh_call.cc: Avoid "set but not used" warning
When building with -fno-exceptions, bad_exception_allowed is set but
not used, causing a warning during the build.

This patch adds __attribute__((unused)) to avoid it.

2020-09-11  Torbjörn SVENSSON  <torbjorn.svensson@st.com>
	    Christophe Lyon  <christophe.lyon@linaro.org>

	libstdc++-v3/
	* libsupc++/eh_call.cc: Avoid warning with -fno-exceptions.
2020-09-11 13:00:29 +00:00
Christophe Lyon
fb00a9fc39 libstdc++-v3/libsupc++/eh_call.cc: Avoid warning with -fno-exceptions.
When building with -fno-exceptions, __throw_exception_again expands to
nothing, causing a "suggest braces around empty body in an 'if'
statement" warning.

This patch adds braces, like what was done in eh_personality.cc in svn
r193295 (git g:54ba39f599fc2f3d59fd3cd828a301ce9b731a20)

2020-09-11  Torbjörn SVENSSON  <torbjorn.svensson@st.com>
	    Christophe Lyon  <christophe.lyon@linaro.org>

	libstdc++-v3/
	* libsupc++/eh_call.cc: Avoid warning with -fno-exceptions.
2020-09-11 13:00:23 +00:00
Christophe Lyon
b32d2ea8c2 libstdc++-v3/include/bits/regex_error.h: Avoid warning with -fno-exceptions.
When building with -fno-exceptions, __GLIBCXX_THROW_OR_ABORT expands to
abort(), causing warnings:
unused parameter '__ecode'
unused parameter '__what'

This patch adds __attribute__((unused)) to avoid them.

2020-09-11  Torbjörn SVENSSON <torbjorn.svensson@st.com>
	    Christophe Lyon  <christophe.lyon@linaro.org>

	libstdc++-v3/
	* include/bits/regex_error.h: Avoid warning with -fno-exceptions.
2020-09-11 13:00:13 +00:00