gcc.git
5 years agoMerge dmd upstream 5220ad51e
Iain Buclaw [Sun, 2 Dec 2018 11:47:49 +0000 (11:47 +0000)]
Merge dmd upstream 5220ad51e

Backports Ddoc fix that is present in upstream, but did not make its way
into the C++ port of the D front-end implementation.

The old special types for C long, unsigned long, and long double have
also been removed as neither the compiler nor druntime bindings support
handling it anymore.

Commits merged from dmd.

Backport Issue 14633: Fixed false DDoc warnings
https://github.com/dlang/dmd/pull/9027

Remove old support code for struct __c_long/ulong/long_double
https://github.com/dlang/dmd/pull/9028

From-SVN: r266719

5 years agoDaily bump.
GCC Administrator [Sun, 2 Dec 2018 00:16:22 +0000 (00:16 +0000)]
Daily bump.

From-SVN: r266717

5 years agore PR c++/87523 (ICE: Closures apparently fail to capture constexpr)
Marek Polacek [Sat, 1 Dec 2018 21:53:07 +0000 (21:53 +0000)]
re PR c++/87523 (ICE: Closures apparently fail to capture constexpr)

PR c++/87523
* g++.dg/cpp1y/lambda-generic-87523.C: New test.

From-SVN: r266714

5 years agolibphobos: Add support for RISCV to glibc bindings
Iain Buclaw [Sat, 1 Dec 2018 21:48:43 +0000 (21:48 +0000)]
libphobos: Add support for RISCV to glibc bindings

Backported from upstream druntime master.

Reviewed-on: https://github.com/dlang/druntime/pull/2355

From-SVN: r266713

5 years agore PR c++/79629 (ICE on invalid code in tsubst_copy, at cp/pt.c:14477)
Marek Polacek [Sat, 1 Dec 2018 21:32:16 +0000 (21:32 +0000)]
re PR c++/79629 (ICE on invalid code in tsubst_copy, at cp/pt.c:14477)

PR c++/79629
* g++.dg/other/error35.C: New test.

From-SVN: r266712

5 years agore PR c++/83856 (ICE in tsubst_copy;)
Marek Polacek [Sat, 1 Dec 2018 21:09:31 +0000 (21:09 +0000)]
re PR c++/83856 (ICE in tsubst_copy;)

PR c++/83856
* g++.dg/cpp1y/lambda-generic-83856.C: New test.

From-SVN: r266711

5 years agoImplement P0634R3, Down with typename!
Marek Polacek [Sat, 1 Dec 2018 17:56:27 +0000 (17:56 +0000)]
Implement P0634R3, Down with typename!

* parser.c (CP_PARSER_FLAGS_TYPENAME_OPTIONAL): New enumerator.
(cp_parser_type_name): Remove declaration.
(cp_parser_postfix_expression): Pass CP_PARSER_FLAGS_TYPENAME_OPTIONAL
to cp_parser_type_id.
(cp_parser_new_type_id): Pass CP_PARSER_FLAGS_TYPENAME_OPTIONAL to
cp_parser_type_specifier_seq.
(cp_parser_lambda_declarator_opt): Pass
CP_PARSER_FLAGS_TYPENAME_OPTIONAL to
cp_parser_parameter_declaration_clause.
(cp_parser_condition): Pass CP_PARSER_FLAGS_NONE to
cp_parser_declarator.
(cp_parser_simple_declaration): Pass CP_PARSER_FLAGS_NONE to
cp_parser_init_declarator.
(cp_parser_conversion_type_id): Pass CP_PARSER_FLAGS_NONE to
cp_parser_type_specifier_seq.
(cp_parser_default_type_template_argument): Pass
CP_PARSER_FLAGS_TYPENAME_OPTIONAL to cp_parser_type_id.
(cp_parser_template_parameter): Pass CP_PARSER_FLAGS_TYPENAME_OPTIONAL
to cp_parser_parameter_declaration.
(cp_parser_explicit_instantiation): Pass CP_PARSER_FLAGS_NONE to
cp_parser_declarator.
(cp_parser_simple_type_specifier): Adjust call to cp_parser_type_name
to relay if we should treat the typename keyword as optional.  Maybe
call cp_parser_make_typename_type is parsing a template-id and it's
not a TYPE_DECL.
(cp_parser_type_name): Remove unused function.
(cp_parser_enum_specifier): Pass to CP_PARSER_FLAGS_NONE
cp_parser_type_specifier_seq.
(cp_parser_alias_declaration): Pass CP_PARSER_FLAGS_TYPENAME_OPTIONAL
to cp_parser_type_id.
(cp_parser_init_declarator): New parameter.  Pass it down to
cp_parser_declarator.
(cp_parser_declarator): New parameter.  Pass CP_PARSER_FLAGS_NONE to
cp_parser_declarator.  Pass the new parameter to
cp_parser_direct_declarator.
(cp_parser_direct_declarator): New parameter.  Pass it to
cp_parser_parameter_declaration_clause and cp_parser_declarator.
(cp_parser_declarator_id):
(cp_parser_type_id_1): New parameter.  Pass it to
cp_parser_type_specifier_seq.  Adjust call to cp_parser_declarator.
(cp_parser_type_id): New parameter.  Pass it to cp_parser_type_id_1.
(cp_parser_template_type_arg): Pass CP_PARSER_FLAGS_NONE to
cp_parser_type_id_1.
(cp_parser_trailing_type_id): Pass CP_PARSER_FLAGS_TYPENAME_OPTIONAL
to cp_parser_type_id_1.
(cp_parser_type_specifier_seq): New parameter.
(function_being_declared_is_template_p):
(cp_parser_parameter_declaration_clause): New parameter.  Pass it to
cp_parser_parameter_declaration_list.
(cp_parser_parameter_declaration_list): New parameter.  Pass it to
cp_parser_parameter_declaration.
(cp_parser_parameter_declaration): New parameter.  Pass it to
cp_parser_decl_specifier_seq.  Pass CP_PARSER_FLAGS_NONE to
cp_parser_declarator.
(cp_parser_member_declaration): Adjust call to
cp_parser_decl_specifier_seq to also include
CP_PARSER_FLAGS_TYPENAME_OPTIONAL.  Pass
CP_PARSER_FLAGS_TYPENAME_OPTIONAL to cp_parser_declarator.
(cp_parser_exception_declaration): Pass CP_PARSER_FLAGS_NONE to
cp_parser_type_specifier_seq and cp_parser_declarator.
(cp_parser_requirement_parameter_list): Pass CP_PARSER_FLAGS_NONE to
cp_parser_parameter_declaration_clause.
(cp_parser_constructor_declarator_p): Resolve the TYPENAME_TYPE.
(cp_parser_single_declaration): Pass CP_PARSER_FLAGS_TYPENAME_OPTIONAL
to cp_parser_decl_specifier_seq and cp_parser_init_declarator.
(cp_parser_cache_defarg): Pass CP_PARSER_FLAGS_NONE to
cp_parser_declarator and cp_parser_parameter_declaration_list.
(cp_parser_objc_method_tail_params_opt): Pass CP_PARSER_FLAGS_NONE to
cp_parser_parameter_declaration.
(cp_parser_objc_class_ivars): Pass CP_PARSER_FLAGS_NONE to
cp_parser_declarator.
(cp_parser_objc_try_catch_finally_statement): Pass CP_PARSER_FLAGS_NONE
to cp_parser_parameter_declaration
(cp_parser_objc_struct_declaration): Pass CP_PARSER_FLAGS_NONE to
cp_parser_declarator.
(cp_parser_omp_for_loop_init): Pass CP_PARSER_FLAGS_NONE to
cp_parser_declarator and cp_parser_type_specifier_seq.

* g++.dg/cpp0x/alias-decl-43.C: Adjust dg-error.
* g++.dg/cpp0x/decltype67.C: Only expect error in c++17_down.
* g++.dg/cpp1z/typename1.C: New test.
* g++.dg/cpp2a/typename1.C: New test.
* g++.dg/cpp2a/typename10.C: New test.
* g++.dg/cpp2a/typename11.C: New test.
* g++.dg/cpp2a/typename2.C: New test.
* g++.dg/cpp2a/typename3.C: New test.
* g++.dg/cpp2a/typename4.C: New test.
* g++.dg/cpp2a/typename5.C: New test.
* g++.dg/cpp2a/typename6.C: New test.
* g++.dg/cpp2a/typename7.C: New test.
* g++.dg/cpp2a/typename8.C: New test.
* g++.dg/cpp2a/typename9.C: New test.
* g++.dg/diagnostic/missing-typename.C: Only run the test in
c++17_down.
* g++.dg/other/crash-9.C: Add template disambiguator.
* g++.dg/other/nontype-1.C: Only expect error in c++17_down.
* g++.dg/parse/crash13.C: Likewise.
* g++.dg/parse/error36.C: Likewise.
* g++.dg/parse/no-typename1.C: Likewise.
* g++.dg/parse/typedef2.C: Likewise.
* g++.dg/parse/typename11.C: Likewise.
* g++.dg/template/crash48.C: Adjust dg-error.
* g++.dg/template/dependent-name5.C: Only expect error in c++17_down.
Add dg-error.
* g++.dg/template/error29.C: Only expect error in c++17_down.
* g++.dg/template/nested5.C: Add template disambiguator.
* g++.dg/template/pr84789.C: Only expect error in c++17_down.
* g++.dg/template/static30.C: Add dg-error.
* g++.dg/template/typedef6.C: Adjust dg-error.
* g++.dg/template/typename3.C: Only expect error in c++17_down.

From-SVN: r266710

6 years ago* gcc.dg/predict-22.c: Update expected output.
Jeff Law [Sat, 1 Dec 2018 16:52:22 +0000 (09:52 -0700)]
* gcc.dg/predict-22.c: Update expected output.

From-SVN: r266709

6 years agore PR sanitizer/88289 (r266664 causes asan to fail on many/most tests on BE)
Jakub Jelinek [Sat, 1 Dec 2018 07:31:56 +0000 (08:31 +0100)]
re PR sanitizer/88289 (r266664 causes asan to fail on many/most tests on BE)

PR sanitizer/88289
* asan.c (asan_redzone_buffer::flush_redzone_payload): Fix up
an off-by-one for BYTES_BIG_ENDIAN.

From-SVN: r266708

6 years agore PR target/54589 (struct offset add should be folded into address calculation)
Jakub Jelinek [Sat, 1 Dec 2018 07:27:58 +0000 (08:27 +0100)]
re PR target/54589 (struct offset add should be folded into address calculation)

PR target/54589
* combine.c (find_split_point): For invalid memory address
nonobj + obj + const, if reg + obj + const is valid addressing
mode, split at nonobj.  Use if rather than else if for the
fallback.  Comment fixes.

* gcc.target/i386/pr54589.c: New test.

From-SVN: r266707

6 years agoDaily bump.
GCC Administrator [Sat, 1 Dec 2018 00:16:41 +0000 (00:16 +0000)]
Daily bump.

From-SVN: r266705

6 years agocoverage.c (get_coverage_counts): Use from_function_decl for precise function location.
Indu Bhagat [Fri, 30 Nov 2018 23:54:30 +0000 (23:54 +0000)]
coverage.c (get_coverage_counts): Use from_function_decl for precise function location.

* coverage.c (get_coverage_counts): Use from_function_decl for precise
function location.
* profile-count.c (profile_count::dump): Add handling for precise
profile quality.
* profile.c (compute_branch_probabilities): Rely on exec_counts instead
of profile_info to set profile_status of function.
(branch_prob): Do not set profile_status of function based on
profile_info. Done above based on exec_counts.

From-SVN: r266702

6 years agore PR tree-optimization/88274 (ICE in check, at tree-vrp.c:188)
Jakub Jelinek [Fri, 30 Nov 2018 23:27:23 +0000 (00:27 +0100)]
re PR tree-optimization/88274 (ICE in check, at tree-vrp.c:188)

PR tree-optimization/88274
* tree-ssa-reassoc.c (optimize_range_tests_xor,
optimize_range_tests_diff): If type has smaller precision than
corresponding mode or if it has non-standard min/max, compute
everything in a standard type for the precision.

From-SVN: r266701

6 years agore PR testsuite/85368 (phi-opt-11 test fails on IBM Z)
Jakub Jelinek [Fri, 30 Nov 2018 23:26:41 +0000 (00:26 +0100)]
re PR testsuite/85368 (phi-opt-11 test fails on IBM Z)

PR testsuite/85368
* params.def (PARAM_LOGICAL_OP_NON_SHORT_CIRCUIT): New param.
* tree-ssa-ifcombine.c (ifcombine_ifandif): If
--param logical-op-non-short-circuit is present, override
LOGICAL_OP_NON_SHORT_CIRCUIT value from the param.
* fold-const.c (fold_range_test, fold_truth_andor): Likewise.

* lib/target-supports.exp (logical_op_short_circuit): Remove.
* gcc.dg/builtin-bswap-7.c: Remove logical_op_short_circuit
effective target, drop -mbranch-cost= options from the test and
instead pass --param logical-op-non-short-circuit=0 or
--param logical-op-non-short-circuit=1 depending on what the
tests meant to test.
* gcc.dg/pr21643.c: Likewise.
* gcc.dg/tree-ssa/ssa-ifcombine-ccmp-2.c: Likewise.
* gcc.dg/tree-ssa/phi-opt-11.c: Likewise.
* gcc.dg/tree-ssa/ssa-ifcombine-ccmp-1.c: Likewise.
* gcc.dg/tree-ssa/ssa-dom-thread-4.c: Likewise.
* gcc.dg/tree-ssa/ssa-ifcombine-ccmp-3.c: Likewise.
* gcc.dg/tree-ssa/ssa-thread-14.c: Likewise.
* gcc.dg/tree-ssa/vrp47.c: Likewise.
* gcc.dg/tree-ssa/ssa-dom-thread-11.c: Likewise.
* gcc.dg/tree-ssa/ssa-dom-thread-16.c: Likewise.
* gcc.dg/tree-ssa/ssa-dom-thread-14.c: Likewise.
* gcc.dg/tree-ssa/ssa-ifcombine-ccmp-5.c: Likewise.
* gcc.dg/tree-ssa/vrp87.c: Likewise.
* gcc.dg/tree-ssa/ssa-ifcombine-ccmp-6.c: Likewise.
* gcc.dg/tree-ssa/phi-opt-2.c: Likewise.
* gcc.dg/tree-ssa/ssa-ifcombine-13.c: Likewise.
* gcc.dg/tree-ssa/ssa-thread-11.c: Likewise.
* gcc.dg/tree-ssa/ssa-ifcombine-ccmp-4.c: Likewise.
* gcc.dg/tree-ssa/forwprop-28.c: Likewise.
* gcc.dg/binop-xor1.c: Likewise.
* gcc.dg/pr46309.c: Likewise.
* gcc.dg/tree-ssa/ssa-dom-thread-18.c: New test.
* gcc.dg/tree-ssa/reassoc-32.c: Add
--param logical-op-non-short-circuit=1 to dg-options.
* gcc.dg/tree-ssa/reassoc-33.c: Likewise.
* gcc.dg/tree-ssa/reassoc-34.c: Likewise.
* gcc.dg/tree-ssa/reassoc-35.c: Likewise.
* gcc.dg/tree-ssa/reassoc-36.c: Likewise.

From-SVN: r266700

6 years agooptabs.c (expand_binop): Use "machine_mode" rather than "enum machine mode" in most...
Jeff Law [Fri, 30 Nov 2018 23:12:59 +0000 (16:12 -0700)]
optabs.c (expand_binop): Use "machine_mode" rather than "enum machine mode" in most recent change.

* optabs.c (expand_binop): Use "machine_mode" rather than
"enum machine mode" in most recent change.

From-SVN: r266698

6 years agore PR middle-end/64242 (Longjmp expansion incorrect)
Wilco Dijkstra [Fri, 30 Nov 2018 23:06:51 +0000 (23:06 +0000)]
re PR middle-end/64242 (Longjmp expansion incorrect)

PR middle-end/64242
* builtins.c (expand_builtin_longjmp): Use a temporary when restoring
the frame pointer.
(expand_builtin_nonlocal_goto): Likewise.

* gcc.c-torture/execute/pr64242.c: New test.

From-SVN: r266697

6 years agoC++: fix-it hint for missing parentheses
David Malcolm [Fri, 30 Nov 2018 22:51:18 +0000 (22:51 +0000)]
C++: fix-it hint for missing parentheses

Consider:

  class t1
  {
  public:
    double length () const { return m_length; }
  private:
    double m_length;
  };

missing-parens-fixit.C: In function 'bool test_1(const t1&)':
missing-parens-fixit.C:14:15: error: invalid use of member function
  'double t1::length() const' (did you forget the '()' ?)
   14 |   return inst.length > 0.0;
      |          ~~~~~^~~~~~

This patch adds a fix-it hint for the case where the member function
takes no parameters, suggesting the addition of the parentheses:

   14 |   return inst.length > 0.0;
      |          ~~~~~^~~~~~
      |                     ()

so that an IDE can potentially apply the fix.

gcc/cp/ChangeLog:
* typeck2.c: Include "gcc-rich-location.h".
(cxx_incomplete_type_diagnostic): When complaining about possibly
missing parens, add a fix-it hint if the member function takes no
additional params.

gcc/ChangeLog:
* diagnostic-core.h (emit_diagnostic): New decl.
* diagnostic.c (emit_diagnostic): New overload, taking a
rich_location *.

gcc/testsuite/ChangeLog:
* g++.dg/parse/missing-parens-fixit.C: New test.

From-SVN: r266696

6 years agopretty-print.c: add selftest::test_prefixes_and_wrapping
David Malcolm [Fri, 30 Nov 2018 22:46:45 +0000 (22:46 +0000)]
pretty-print.c: add selftest::test_prefixes_and_wrapping

gcc/ChangeLog:
* pretty-print.c (class selftest::test_pretty_printer): New
subclass of pretty_printer.
(selftest::test_prefixes_and_wrapping): New test.
(selftest::pretty_print_c_tests): Call it.

From-SVN: r266695

6 years agoMinimize clone counter memory usage in LTO.
Michael Ploujnikov [Fri, 30 Nov 2018 22:31:02 +0000 (22:31 +0000)]
Minimize clone counter memory usage in LTO.

gcc/lto:

* lto-partition.c (privatize_symbol_name_1): Keep track of
non-unique symbol counters in the lto_clone_numbers hash
map.
(lto_promote_cross_file_statics): Allocate and free the
lto_clone_numbers hash map.
(lto_promote_statics_nonwpa): Free the lto_clone_numbers hash
map.

From-SVN: r266693

6 years agoMinimize clone counter memory usage in create_virtual_clone.
Michael Ploujnikov [Fri, 30 Nov 2018 22:27:11 +0000 (22:27 +0000)]
Minimize clone counter memory usage in create_virtual_clone.

Based on Martin Jambour's suggestion:
https://gcc.gnu.org/ml/gcc-patches/2018-09/msg00111.html

gcc:

* cgraph.h (clone_function_name): Add a variant that takes a
tree decl.
* cgraph.h (cgraph_node::create_virtual_clone): Add a new
argument: num_suffix.
* cgraphclones.c (cgraph_node::create_virtual_clone): Pass
num_suffix to clone_function_name.
(clone_function_name): Add a variant that takes a tree decl.
* ipa-cp.c (create_specialized_node): Keep track of clone
counters in clone_num_suffixes hash map.
(ipcp_driver): Free the counter hash map.
* ipa-hsa.c (process_hsa_functions): Creates at most one hsa
clone per function.

From-SVN: r266692

6 years agoMake function assembly more independent.
Michael Ploujnikov [Fri, 30 Nov 2018 22:20:43 +0000 (22:20 +0000)]
Make function assembly more independent.

This is achieved by having clone_function_name assign unique clone
numbers for each function independently.

gcc:

* cgraphclones.c: Replaced clone_fn_id_num with clone_fn_ids;
hash map.
(clone_function_name_numbered): Use clone_fn_ids.

gcc/testsuite:

* gcc.dg/independent-cloneids-1.c: New test.

From-SVN: r266691

6 years agore PR debug/85550 (-fdebug-types-section broken with DW_OP_addr in DW_AT_location)
Jakub Jelinek [Fri, 30 Nov 2018 20:55:41 +0000 (21:55 +0100)]
re PR debug/85550 (-fdebug-types-section broken with DW_OP_addr in DW_AT_location)

PR debug/85550
* g++.dg/debug/dwarf2/pr85550.C: New test.

From-SVN: r266689

6 years ago[PR88288, OpenACC, libgomp] Adjust offsets for present data clauses
Cesar Philippidis [Fri, 30 Nov 2018 20:39:49 +0000 (12:39 -0800)]
[PR88288, OpenACC, libgomp] Adjust offsets for present data clauses

Make libgomp respect the on device offset of subarrays which may arise in
present data clauses.

libgomp/
PR libgomp/88288
* oacc-parallel.c (GOACC_parallel_keyed): Add offset to devaddrs.
* testsuite/libgomp.oacc-c-c++-common/pr88288.c: New test.

Reviewed-by: Thomas Schwinge <thomas@codesourcery.com>
From-SVN: r266688

6 years ago[C++] Use existing local variable in cp_parser_oacc_enter_exit_data
James Norris [Fri, 30 Nov 2018 20:39:40 +0000 (20:39 +0000)]
[C++] Use existing local variable in cp_parser_oacc_enter_exit_data

gcc/cp/
* parser.c (cp_parser_oacc_enter_exit_data): Use existing local
variable.

Reviewed-by: Thomas Schwinge <thomas@codesourcery.com>
From-SVN: r266687

6 years ago[PR87924] Add (XFAILed) test cases for OpenACC wait clauses without async-arguments
Thomas Schwinge [Fri, 30 Nov 2018 20:39:30 +0000 (21:39 +0100)]
[PR87924] Add (XFAILed) test cases for OpenACC wait clauses without async-arguments

gcc/testsuite/
PR c/87924
* c-c++-common/goacc/asyncwait-5.c: Update.
* gfortran.dg/goacc/asyncwait-5.f: Likewise.

From-SVN: r266686

6 years agoClean up Fortran OpenACC wait clause handling
Thomas Schwinge [Fri, 30 Nov 2018 20:39:18 +0000 (21:39 +0100)]
Clean up Fortran OpenACC wait clause handling

"wait" can be deduced from "wait_list".

gcc/fortran/
* gfortran.h (struct gfc_omp_clauses): Remove "wait".  Adjust all
users.

From-SVN: r266685

6 years agoSupport multiple OpenACC wait clauses
Thomas Schwinge [Fri, 30 Nov 2018 20:39:08 +0000 (21:39 +0100)]
Support multiple OpenACC wait clauses

Support for this is not explicitly called for in OpenACC 2.6, but given that
GCC internally decomposes "wait (1, 2)" into "wait (1) wait (2)" (similar for
other clauses, too), it's reasonable to also support that syntax in the front
ends -- which happens to already be the case for C, C++, and easy enough to do
for Fortran.

gcc/fortran/
* openmp.c (gfc_match_omp_clauses): Support multiple OpenACC wait
clauses.
gcc/testsuite/
* c-c++-common/goacc/asyncwait-5.c: New file.
* gfortran.dg/goacc/asyncwait-5.f: Likewise.

From-SVN: r266684

6 years agoAdd libgomp.oacc-fortran/lib-16-2.f90
Thomas Schwinge [Fri, 30 Nov 2018 20:38:57 +0000 (21:38 +0100)]
Add libgomp.oacc-fortran/lib-16-2.f90

This is a copy of libgomp.oacc-fortran/lib-16.f90, but does 'include
"openacc_lib.h"' instead of 'use openacc'.

libgomp/
* testsuite/libgomp.oacc-fortran/lib-16-2.f90: New file.

From-SVN: r266683

6 years agore PR rtl-optimization/88179 ([MIPS] pr84941.c ICE in lra_eliminate_reg_if_possible...
Vladimir Makarov [Fri, 30 Nov 2018 20:15:56 +0000 (20:15 +0000)]
re PR rtl-optimization/88179 ([MIPS]  pr84941.c ICE in lra_eliminate_reg_if_possible at lra-eliminations.c:1393  start with r266385)

2018-11-30  Vladimir Makarov  <vmakarov@redhat.com>

PR rtl-optimization/88179
* lra-constraints.c (address_eliminator::address_eliminator):
Don't eleminate regs in illegitimate address.

From-SVN: r266682

6 years agore PR target/87496 (ICE in aggregate_value_p at gcc/function.c:2046)
Peter Bergner [Fri, 30 Nov 2018 18:57:33 +0000 (18:57 +0000)]
re PR target/87496 (ICE in aggregate_value_p at gcc/function.c:2046)

gcc/testsuite/
PR target/87496
* gcc.target/powerpc/pr86324-1.c: Add dg-skip-if selector.
Add -mcpu=power7 option.

From-SVN: r266680

6 years agoInitialize backtrace state once
Janne Blomqvist [Fri, 30 Nov 2018 16:44:27 +0000 (18:44 +0200)]
Initialize backtrace state once

From backtrace.h for backtrace_create_state:

   Calling this function allocates resources that can not be freed.
   There is no backtrace_free_state function.  The state is used to
   cache information that is expensive to recompute.  Programs are
   expected to call this function at most once and to save the return
   value for all later calls to backtrace functions.

So instead of calling backtrace_create_state every time we wish to
show a backtrace, do it once and store the result in a static
variable.  libbacktrace allows multiple threads to access the state,
so no need to use TLS.

Regtested on x86_64-pc-linux-gnu.

libgfortran/ChangeLog:

2018-11-30  Janne Blomqvist  <jb@gcc.gnu.org>

PR libfortran/88137
* runtime/backtrace.c (show_backtrace): Make lbstate a static
variable, initialize once.

From-SVN: r266677

6 years agoImplement P0457R2 String Prefix and Suffix Checking.
Edward Smith-Rowland [Fri, 30 Nov 2018 16:26:02 +0000 (16:26 +0000)]
Implement P0457R2 String Prefix and Suffix Checking.

2018-11-30  Edward Smith-Rowland  <3dw4rd@verizon.net>

Implement P0457R2 String Prefix and Suffix Checking.
* include/bits/basic_string.h: Add starts_with, ends_with members.
* include/std/string_view: Ditto.
* testsuite/21_strings/basic_string/operations/starts_with/
char/1.cc: New test.
* testsuite/21_strings/basic_string/operations/starts_with/
wchar_t/1.cc: New test.
* testsuite/21_strings/basic_string/operations/ends_with/
char/1.cc: New test.
* testsuite/21_strings/basic_string/operations/ends_with/
wchar_t/1.cc: New test.
* testsuite/21_strings/basic_string_view/operations/starts_with/
char/1.cc: New test.
* testsuite/21_strings/basic_string_view/operations/starts_with/
wchar_t/1.cc: New test.
* testsuite/21_strings/basic_string_view/operations/ends_with/
char/1.cc: New test.
* testsuite/21_strings/basic_string_view/operations/ends_with/
wchar_t/1.cc: New test.

From-SVN: r266674

6 years agoThe remainder of the Pre-emptively support P0646R1 for std container erasure.
Edward Smith-Rowland [Fri, 30 Nov 2018 16:13:29 +0000 (16:13 +0000)]
The remainder of the Pre-emptively support P0646R1 for std container erasure.

From-SVN: r266673

6 years agoPre-emptively support P0646R1 for std container erasure.
Edward Smith-Rowland [Fri, 30 Nov 2018 16:12:13 +0000 (16:12 +0000)]
Pre-emptively support P0646R1 for std container erasure.

2018-11-30  Edward Smith-Rowland  <3dw4rd@verizon.net>

Pre-emptively support P0646R1 for std container erasure.
* include/bits/erase_if.h: Accumulate and return number of erased nodes.
* include/std/forward_list (): Return number of erased items.
* include/std/list (): Ditto.
* include/std/map (): Ditto.
* include/std/set (): Ditto.
* include/std/string (): Ditto.
* include/std/unordered_map (): Ditto.
* include/std/unordered_set (): Ditto.
* include/std/vector (): Ditto.
* testsuite/21_strings/basic_string/erasure.cc: Test number of erasures.
* testsuite/23_containers/deque/erasure.cc: Ditto.
* testsuite/23_containers/forward_list/erasure.cc: Ditto.
* testsuite/23_containers/list/erasure.cc: Ditto.
* testsuite/23_containers/map/erasure.cc: Ditto.
* testsuite/23_containers/set/erasure.cc: Ditto.
* testsuite/23_containers/unordered_map/erasure.cc: Ditto.
* testsuite/23_containers/unordered_set/erasure.cc: Ditto.
* testsuite/23_containers/vector/erasure.cc: Ditto.

From-SVN: r266672

6 years agoFix ICE in substring locations from macros in header files (PR preprocessor/88257)
David Malcolm [Fri, 30 Nov 2018 15:57:37 +0000 (15:57 +0000)]
Fix ICE in substring locations from macros in header files (PR preprocessor/88257)

PR preprocessor/88257 reports an ICE on gcc.dg/format/pr78304.c
when compiled using g++:

void test (const char *msg)
{
  printf ("size: %" PRIu32 "\n", msg);
}

due to mismatching files (and line maps) between
linemap_resolve_location and expand_location_to_spelling_point
when PRIu32 is defined in a system header.

The root cause is that expand_location_to_spelling_point stops
unwinding locations when it reaches a system header, whereas
linemap_resolve_location can resolve into a system header,
which can lead to locations within get_substring_ranges_for_loc
getting out of sync, and using the wrong line map.

This patch fixes the issue by checking that the files are the
same.

gcc/ChangeLog:
PR preprocessor/88257
* input.c (get_substring_ranges_for_loc): Fix indentation.
Bulletproof against getting a different files back from
linemap_resolve_location and expand_location_to_spelling_point.

gcc/testsuite/ChangeLog:
PR preprocessor/88257
* c-c++-common/Wformat-pr88257.c: New test.
* c-c++-common/Wformat-pr88257.h: New test header.
* c-c++-common/empty.h: New test header.

From-SVN: r266671

6 years ago[libbacktrace] Add tests for unused formats
Tom de Vries [Fri, 30 Nov 2018 15:33:23 +0000 (15:33 +0000)]
[libbacktrace] Add tests for unused formats

When building libbacktrace, we typically use elf.c, and don't build pecoff.c,
xcoff.c or unknown.c.

Add testcases that use unused format to ensure that we also build and
test those on a typical development setup.

Bootstrapped and reg-tested on x86_64.

2018-11-30  Tom de Vries  <tdevries@suse.de>

* Makefile.am (check_PROGRAMS): Add test_elf, test_xcoff_32,
test_xcoff_64, test_pecoff and test_unknown.
* Makefile.in: Regenerate.
* test_format.c: New file.

From-SVN: r266668

6 years ago[libbacktrace] Test check_PROGRAMS without mmap
Tom de Vries [Fri, 30 Nov 2018 15:33:12 +0000 (15:33 +0000)]
[libbacktrace] Test check_PROGRAMS without mmap

When building libbacktrace, we typically use mmapio.c and mmap.c, and don't
build read.c and alloc.c.

Add testcases that use read.c and alloc.c to ensure that we also build and
test those on a typical development setup.

Bootstrapped and reg-tested on x86_64.

2018-11-30  Tom de Vries  <tdevries@suse.de>

* Makefile.am : Add _with_alloc version for each test in
check_PROGRAMS.
* Makefile.in: Regenerate.

From-SVN: r266667

6 years agoCall decl_default_tls_model with a proper type (PR gcov-profile/88279).
Alexander Monakov [Fri, 30 Nov 2018 15:06:22 +0000 (18:06 +0300)]
Call decl_default_tls_model with a proper type (PR gcov-profile/88279).

2018-11-30  Alexander Monakov  <amonakov@ispras.ru>

PR gcov-profile/88279
* tree-profile.c (init_ic_make_global_vars): Call
decl_default_tls_model for variable and not it's type.

From-SVN: r266666

6 years ago[PATCH][GCC][ARM] Ensure dotproduct is only enabled on armv8 neon
Sam Tebbs [Fri, 30 Nov 2018 14:38:11 +0000 (14:38 +0000)]
[PATCH][GCC][ARM] Ensure dotproduct is only enabled on armv8 neon

gcc/ChangeLog:

2018-11-30  Sam Tebbs<sam.tebbs@arm.com>

* config/arm/arm.h (TARGET_DOTPROD): Add TARGET_VFP5 constraint.

gcc/testsuite/ChangeLog:

2018-11-30  Sam Tebbs<sam.tebbs@arm.com>

* gcc.target/arm/neon-dotprod-restriction.c: New file.
* lib/target-supports.exp
(check_effective_target_arm_v8_2a_dotprod_neon_ok_nocache): Include
stdint.h.

From-SVN: r266665

6 years agoMake red zone size more flexible for stack variables (PR sanitizer/81715).
Martin Liska [Fri, 30 Nov 2018 14:25:15 +0000 (15:25 +0100)]
Make red zone size more flexible for stack variables (PR sanitizer/81715).

2018-11-30  Martin Liska  <mliska@suse.cz>

PR sanitizer/81715
* asan.c (asan_shadow_cst): Remove, partially transform
into flush_redzone_payload.
(RZ_BUFFER_SIZE): New.
(struct asan_redzone_buffer): New.
(asan_redzone_buffer::emit_redzone_byte): Likewise.
(asan_redzone_buffer::flush_redzone_payload): Likewise.
(asan_redzone_buffer::flush_if_full): Likewise.
(asan_emit_stack_protection): Use asan_redzone_buffer class
that is responsible for proper aligned stores and flushing
of shadow memory payload.
* asan.h (ASAN_MIN_RED_ZONE_SIZE): New.
(asan_var_and_redzone_size): Likewise.
* cfgexpand.c (expand_stack_vars): Use smaller alignment
(ASAN_MIN_RED_ZONE_SIZE) in order to make shadow memory
for automatic variables more compact.
2018-11-30  Martin Liska  <mliska@suse.cz>

PR sanitizer/81715
* c-c++-common/asan/asan-stack-small.c: New test.

From-SVN: r266664

6 years ago[RS6000] PowerPC64 soft-float
Alan Modra [Fri, 30 Nov 2018 13:35:25 +0000 (00:05 +1030)]
[RS6000] PowerPC64 soft-float

This patch aims to prevent long sequences loading soft-float
constants.  For 32-bit, it makes sense to load values inline to a gpr
with lis, addi, but not so much for 64-bit where a 5 insn sequence
might be needed for each gpr.  For TFmode in particular, a 10 insn
sequence is reduced to 2 loads from memory plus 1 or 2 address setup
insns.

* config/rs6000/predicates.md (easy_fp_constant): Avoid long
dependent insn sequences.
* config/rs6000/rs6000.c (num_insns_constant): Support long
double constants.
* config/rs6000/rs6000.md (mov<mode>_softfloat <FMOVE128>): Adjust
length attribute.

From-SVN: r266663

6 years ago[RS6000] num_insns_constant ICE
Alan Modra [Fri, 30 Nov 2018 13:33:18 +0000 (00:03 +1030)]
[RS6000] num_insns_constant ICE

This patch came about from investigating an ICE that appeared when I
was retesting an old half-baked patch of mine to rs6000_rtx_costs.
If a const_double is fed to rs6000_is_valid_and_mask and from there to
rs6000_is_valid_mask where INTVAL is used, gcc will ICE.

The num_insns_constant ICE was introduced with git commit f337168d97.
However, the code was buggy before that.  There was no point in
testing for a mask since the mask predicates only handle const_int.
In fact, I don't think the function ever handled floating point
constants that might match a load of minus one and mask.  It does now.
I've added a few comments regarding splitters so the next person
looking at this code can see how this works.

The patch also extracts code out of num_insns_constant that needed to
handle multiple gprs for DFmode constants in 32-bit mode, to a
function that handles multiple gprs a little more generally.  I don't
think there is any need for anything but the 32-bit DFmode case
currently, but this allows for possible future uses.  The
CONST_WIDE_INT case is also not used currently, and needed fixing.
Adding CONST_WIDE_INT_NUNITS - 1 only makes sense if the elements of
the array were being shifted into a register of size larger than the
element size (which is 64-bits).

* config/rs6000/rs6000.c (num_insns_constant_gpr): Renamed from
num_insns_constant_wide.  Make static.  Revise comment.
(num_insns_constant_multi): New function.
(num_insns_constant): Formatting.  Correct CONST_WIDE_INT
calculation.  Simplify and extract code common to both
CONST_INT and CONST_DOUBLE.  Add gcc_unreachable for unhandled
const_double modes.
* config/rs6000/rs6000-protos.h (num_insns_const_wide): Delete.

From-SVN: r266662

6 years agogimple-parser.c (c_parser_gimple_postfix_expression): Parse _Literal (type) { ...
Richard Biener [Fri, 30 Nov 2018 12:02:55 +0000 (12:02 +0000)]
gimple-parser.c (c_parser_gimple_postfix_expression): Parse _Literal (type) { ...

2018-11-30  Richard Biener  <rguenther@suse.de>

c/
* gimple-parser.c (c_parser_gimple_postfix_expression): Parse
_Literal (type) { ... } as empty aggregate or vector constructor.

* gcc.dg/gimplefe-34.c: New testcase.
* gcc.dg/gimplefe-35.c: Likewise.

From-SVN: r266661

6 years agoRestrict vector extension to use 128bit vectors (PR testsuite/88265).
Martin Liska [Fri, 30 Nov 2018 10:48:51 +0000 (11:48 +0100)]
Restrict vector extension to use 128bit vectors (PR testsuite/88265).

2018-11-30  Martin Liska  <mliska@suse.cz>

PR testsuite/88265
* gfortran.dg/simd-builtins-1.f90: Restrict to 128b vectors.
* gfortran.dg/simd-builtins-6.f90: Likewise.

From-SVN: r266660

6 years agore PR tree-optimization/88274 (ICE in check, at tree-vrp.c:188)
Richard Biener [Fri, 30 Nov 2018 10:37:39 +0000 (10:37 +0000)]
re PR tree-optimization/88274 (ICE in check, at tree-vrp.c:188)

2018-11-30  Richard Biener  <rguenther@suse.de>

PR tree-optimization/88274
* tree-vrp.c (ranges_from_anti_range): Fix handling of
TYPE_MIN/MAX_VALUE.

From-SVN: r266659

6 years ago[libbacktrace] Factor out backtrace_vector_free
Tom de Vries [Fri, 30 Nov 2018 08:43:50 +0000 (08:43 +0000)]
[libbacktrace] Factor out backtrace_vector_free

Factor out new function backtrace_vector_free.

Bootstrapped and reg-tested on x86_64.

2018-11-30  Tom de Vries  <tdevries@suse.de>

* internal.h (backtrace_vector_free): New static inline fuction,
factored out of ...
* dwarf.c (read_line_info): ... here.

From-SVN: r266658

6 years agoDaily bump.
GCC Administrator [Fri, 30 Nov 2018 00:16:30 +0000 (00:16 +0000)]
Daily bump.

From-SVN: r266657

6 years agoAllow changing the fentry section per file and per function
Andi Kleen [Thu, 29 Nov 2018 23:11:59 +0000 (23:11 +0000)]
Allow changing the fentry section per file and per function

When dynamically patching in/out instrumentation it can be useful
to handle different classes of functions differently. Add support
for changing the fentry section name on the command line
or as a function attributes. This allows to mark functions differently,
and handle them differently in dynamic patching.

gcc/:

2018-11-29  Andi Kleen  <ak@linux.intel.com>

* config/i386/i386.c (current_fentry_section): Add.
(x86_function_profiler): Handle fentry section.
(ix86_attribute_table): Add fentry section.
* config/i386/i386.opt: Add -mfentry-section.
* doc/extend.texi: Document fentry_section attribute.
* doc/invoke.texi: Document -mfentry-section.

gcc/testsuite/:

2018-11-29  Andi Kleen  <ak@linux.intel.com>

* gcc.target/i386/fentryname2.c: New test.
* gcc.target/i386/fentryname3.c: New test.

From-SVN: r266654

6 years agoSupport changing fentry name per function
Andi Kleen [Thu, 29 Nov 2018 23:11:53 +0000 (23:11 +0000)]
Support changing fentry name per function

It can be useful to have some classes of functions that use a different
__fentry__ instrumentation than others.  Currently it is only
possible to disable instrumentation on the command line or with
no_instrument_function, but not to change the instrumentation function
on a case by case base.

Add some flexibility to allow to change the instrumentation function
name per file with an option or per function with a new attribute.
This also allows switching to nops for individual functions.

gcc/:

2018-11-29  Andi Kleen  <ak@linux.intel.com>

* config/i386/i386.c (x86_print_call_or_nop): Handle nop name.
(current_fentry_name): Add.
(x86_function_profiler): Handle fentry_name attribute.
(ix86_handle_fentry_name): Add.
(ix86_attribute_table): Add fentry_name.
* config/i386/i386.opt: Add -mfentry-name
* doc/extend.texi: Document fentry_name.
* doc/invoke.texi: Document minstrument-return.

gcc/testsuite/:

2018-11-29  Andi Kleen  <ak@linux.intel.com>

* gcc.target/i386/fentryname1.c: New test.

From-SVN: r266653

6 years agoSupport instrumenting returns of instrumented functions
Andi Kleen [Thu, 29 Nov 2018 23:11:47 +0000 (23:11 +0000)]
Support instrumenting returns of instrumented functions

When instrumenting programs using __fentry__ it is often useful
to instrument the function return too. Traditionally this
has been done by patching the return address on the stack
frame on entry. However this is fairly complicated (trace
function has to emulate a stack) and also slow because
it causes a branch misprediction on every return.

Add an option to generate call or nop instrumentation for
every return instead, including patch sections.

This will increase the program size slightly, but can be a
lot faster and simpler.

This version only instruments true returns, not sibling
calls or tail recursion. This matches the semantics of the
original stack.

gcc/:

2018-11-29  Andi Kleen  <ak@linux.intel.com>

* config/i386/i386-opts.h (enum instrument_return): Add.
* config/i386/i386.c (output_return_instrumentation): Add.
(ix86_output_function_return): Call output_return_instrumentation.
(ix86_output_call_insn): Call output_return_instrumentation.
* config/i386/i386.opt: Add -minstrument-return=.
* doc/invoke.texi (-minstrument-return): Document.

gcc/testsuite/:

2018-11-29  Andi Kleen  <ak@linux.intel.com>

* gcc.target/i386/returninst1.c: New test.
* gcc.target/i386/returninst2.c: New test.
* gcc.target/i386/returninst3.c: New test.

From-SVN: r266652

6 years agore PR target/87807 (passing float/double vectors as variadic args fails on-64bit...
Eric Botcazou [Thu, 29 Nov 2018 23:08:09 +0000 (23:08 +0000)]
re PR target/87807 (passing float/double vectors as variadic args fails on-64bit SPARC)

PR target/87807
* config/sparc/sparc-modes.def: Minor tweak.
* config/sparc/sparc.c: Minor reordering.
(sparc_pass_by_reference): Move around.
(traverse_record_type): Change offset from HOST_WIDE_INT to int.
(classify_registers): Likewise for bitpos.
(function_arg_slotno): Remove dead test and tweak comments.
<MODE_RANDOM>: Remove useless assertion and test whether the
parameter is named in order to pass it in FP registers.  Return
the regno for floating-point vector types.
(compute_int_layout): Change bitpos from HOST_WIDE_INT to int.
(compute_fp_layout): Likewise.
(count_registers): Likewise.
(assign_int_registers): Likewise.
(assign_fp_registers): Likewise.
(assign_registers): Likewise.
(function_arg_record_value): Change size from HOST_WIDE_INT to int
and use CEIL_NWORDS to compute the number of registers.
(function_arg_union_value): Minor tweaks.
(function_arg_vector_value): Add slotno and named parameters, use
CEIL_NWORDS to compute the number of registers.
(sparc_function_arg_1): Rework handling of vector types.  Change
size from HOST_WIDE_INT to int.
(sparc_arg_partial_bytes): Rework handling of 32-bit ABI and deal
with vector types for the 64-bt ABI.
(sparc_function_arg_advance): Likewise.
(sparc_return_in_memory): Add reference to -fpcc-struct-return.
(sparc_struct_value_rtx): Return NULL_RTX instead of 0.
(sparc_function_value_1): Rework handling of vector types.  Change
size from HOST_WIDE_INT to int.

From-SVN: r266651

6 years agore PR target/88152 (optimize SSE & AVX char compares with subsequent movmskb)
Jakub Jelinek [Thu, 29 Nov 2018 22:16:37 +0000 (23:16 +0100)]
re PR target/88152 (optimize SSE & AVX char compares with subsequent movmskb)

PR target/88152
* config/i386/sse.md (*<sse>_movmsk<ssemodesuffix><avxsizesuffix>_lt,
*<sse>_movmsk<ssemodesuffix><avxsizesuffix>_zext_lt,
*<sse>_movmsk<ssemodesuffix><avxsizesuffix>_shift,
*<sse>_movmsk<ssemodesuffix><avxsizesuffix>_zext_shift,
*<sse2_avx2>_pmovmskb_lt, *<sse2_avx2>_pmovmskb_zext_lt): New
define_insn_and_split patterns.

* g++.target/i386/pr88152.C: New test.

From-SVN: r266649

6 years agore PR target/54700 (Optimize away x<0 as mask argument of a blend.)
Jakub Jelinek [Thu, 29 Nov 2018 22:15:42 +0000 (23:15 +0100)]
re PR target/54700 (Optimize away x<0 as mask argument of a blend.)

PR target/54700
* config/i386/sse.md
(*<sse4_1>_blendv<ssemodesuffix><avxsizesuffix>_lt,
*<sse4_1>_blendv<ssefltmodesuffix><avxsizesuffix>_ltint,
*<sse4_1_avx2>_pblendvb_lt): Change define_insn into
define_insn_and_split.

From-SVN: r266648

6 years agopr34256.c: Adjust the number of expected moves.
Vladimir Makarov [Thu, 29 Nov 2018 22:02:15 +0000 (22:02 +0000)]
pr34256.c: Adjust the number of expected moves.

2018-11-29  Vladimir Makarov  <vmakarov@redhat.com>

* gcc.target/i386/pr34256.c: Adjust the number of expected moves.

From-SVN: r266646

6 years agodecl.c (compute_array_index_type_loc): New, like the current compute_array_index_type...
Paolo Carlini [Thu, 29 Nov 2018 21:34:38 +0000 (21:34 +0000)]
decl.c (compute_array_index_type_loc): New, like the current compute_array_index_type but takes a location_t too.

/cp
2018-11-29  Paolo Carlini  <paolo.carlini@oracle.com>

* decl.c (compute_array_index_type_loc): New, like the current
compute_array_index_type but takes a location_t too.
(compute_array_index_type): Forward to the latter.
(create_array_type_for_decl): Use compute_array_index_type_loc.

/testsuite
2018-11-29  Paolo Carlini  <paolo.carlini@oracle.com>

* g++.dg/cpp0x/constexpr-base6b.C: New.
* g++.dg/cpp0x/constexpr-47969.C: Test locations too.
* g++.dg/cpp0x/constexpr-48324.C: Likewise.
* g++.dg/cpp0x/constexpr-ex2.C: Likewise.
* g++.dg/cpp0x/scoped_enum2.C: Likewise.
* g++.dg/cpp1y/pr63996.C: Likewise.
* g++.dg/ext/constexpr-vla5.C: Likewise.
* g++.dg/ext/stmtexpr15.C: Likewise.
* g++.dg/ext/vla1.C: Likewise.
* g++.dg/other/fold1.C: Likewise.
* g++.dg/parse/array-size2.C: Likewise.
* g++.dg/parse/crash36.C: Likewise.
* g++.dg/ubsan/pr81530.C: Likewise.
* g++.dg/warn/Wvla-1.C: Likewise.
* g++.dg/warn/Wvla-2.C: Likewise.
* g++.old-deja/g++.brendan/array1.C: Likewise.
* g++.old-deja/g++.bugs/900402_02.C: Likewise.
* g++.old-deja/g++.law/init3.C: Likewise.
* g++.old-deja/g++.mike/p6149.C: Likewise.

From-SVN: r266645

6 years agoC++: namespaces and scopes for enum values (PR c++/88121)
David Malcolm [Thu, 29 Nov 2018 21:21:56 +0000 (21:21 +0000)]
C++: namespaces and scopes for enum values (PR c++/88121)

Consider this test case:

namespace json
{
  enum { JSON_OBJECT };
}

void test ()
{
  JSON_OBJECT;
}

which erroneously accesses an enum value in another namespace without
qualifying the access.

GCC 6 through 8 issue a suggestion that doesn't mention the namespace:

<source>: In function 'void test()':
<source>:8:3: error: 'JSON_OBJECT' was not declared in this scope
   JSON_OBJECT;
   ^~~~~~~~~~~
<source>:8:3: note: suggested alternative:
<source>:3:10: note:   'JSON_OBJECT'
   enum { JSON_OBJECT };
          ^~~~~~~~~~~

which is suboptimal.

I made the problem worse with r265610, which consolidates the single
suggestion into the error, and emits:

<source>: In function 'void test()':
<source>:8:3: error: 'JSON_OBJECT' was not declared in this scope; did
   you mean 'JSON_OBJECT'?
    8 |   JSON_OBJECT;
      |   ^~~~~~~~~~~
      |   JSON_OBJECT
<source>:3:10: note: 'JSON_OBJECT' declared here
    3 |   enum { JSON_OBJECT };
      |          ^~~~~~~~~~~

where the message:
  'JSON_OBJECT' was not declared in this scope; did you mean 'JSON_OBJECT'?
is nonsensical.

This patch tweaks dump_scope to detect unscoped enums, and to use the
enclosing namespace for them, so that the CONST_DECL is dumped as
"json::JSON_OBJECT".

This changes the output for the above so that it refers to the
namespace, fixing the issue:

<source>:8:3: error: 'JSON_OBJECT' was not declared in this scope; did
   you mean 'json::JSON_OBJECT'?
    9 |   JSON_OBJECT;
      |   ^~~~~~~~~~~
      |   json::JSON_OBJECT
<source>3:10: note: 'json::JSON_OBJECT' declared here
    3 |   enum { JSON_OBJECT };
      |          ^~~~~~~~~~~

The patch also fixes scope-printing for values within scoped enums.
To exercise this, the patch extends the scanner for namespaces for
exact matches for a name, so that we also scan inside scoped
enums, to cover the case where someone doesn't supply the scope.

Hence with the patch given e.g.:

enum class vegetable { CARROT, TURNIP };

we're able to offer e.g.:

suggestions-scoped-enums.C:50:3: error: 'CARROT' was not declared in
  this scope; did you mean 'vegetable::CARROT'?
   50 |   CARROT;
      |   ^~~~~~
      |   vegetable::CARROT

and this exercises the code path above.  The patch updates dump_scope
for scoped enums so that we print the scope when printing the
value ("vegetable::CARROT"), rather than just the name of the value
("CARROT").

Finally, the patch adds spell-corrections within a scoped enum,
giving e.g.:

suggestions-scoped-enums.C:18:14: error: 'TURNUP' is not a member of
  'vegetable'; did you mean 'TURNIP'?
   18 |   vegetable::TURNUP;
      |              ^~~~~~
      |              TURNIP

gcc/cp/ChangeLog:
PR c++/88121
* cp-name-hint.h (suggest_alternative_in_scoped_enum): New decl.
* error.c (dump_scope): Ensure that we print any scope for values
of unscoped enums.  Print the scope of values of scoped enums.
(qualified_name_lookup_error): Offer suggestions for failures
within scoped enums by calling suggest_alternative_in_scoped_enum.
* name-lookup.c (class namespace_hints): Update comment to mention
scoped enums.
(namespace_hints::namespace_hints): Call
maybe_add_candidate_for_scoped_enum.
(namespace_hints::maybe_add_candidate_for_scoped_enum): New member
(suggest_alternatives_for): Update comment to mention scoped
enums.
(suggest_alternative_in_scoped_enum): New function.

gcc/testsuite/ChangeLog:
PR c++/88121
* g++.dg/lookup/suggestions-scoped-enums.C: New test.
* g++.dg/lookup/suggestions-unscoped-enums.C: New test.

From-SVN: r266644

6 years agore PR target/87496 (ICE in aggregate_value_p at gcc/function.c:2046)
Peter Bergner [Thu, 29 Nov 2018 19:25:47 +0000 (19:25 +0000)]
re PR target/87496 (ICE in aggregate_value_p at gcc/function.c:2046)

gcc/
PR target/87496
* config/rs6000/rs6000.c (rs6000_option_override_internal): Disallow
-mabi=ieeelongdouble without both -mpopcntd and -mvsx.

gcc/testsuite/
PR target/87496
* gcc.target/powerpc/pr87496.c: New test.

From-SVN: r266636

6 years agoi386.c (inline_memory_move_cost): Check "in" for 2 in MMX_CLASS_P case.
Uros Bizjak [Thu, 29 Nov 2018 18:22:30 +0000 (19:22 +0100)]
i386.c (inline_memory_move_cost): Check "in" for 2 in MMX_CLASS_P case.

* config/i386/i386.c (inline_memory_move_cost):
Check "in" for 2 in MMX_CLASS_P case.
* config/i386/mmx.md (*mov<mode>_internal): Correct
TARGET_INTER_UNIT_MOVES_FROM_VEC and TARGET_INTER_UNIT_MOVES_TO_VEC
alternatives in preferred_for_speed attribute calculation.

From-SVN: r266635

6 years agoPR c/88091 - c-c++-common/Wconversion-real.c etc. FAIL
Martin Sebor [Thu, 29 Nov 2018 18:03:18 +0000 (18:03 +0000)]
PR c/88091 - c-c++-common/Wconversion-real.c etc. FAIL

gcc/c/ChangeLog:

PR c/88091
* c-typeck.c (convert_argument): Add a parameter.  Adjust indentation.
(convert_arguments): Add comments.  Pass additional argument to
the function above.

From-SVN: r266634

6 years agoPR c/88172 - attribute aligned of zero silently accepted but ignored
Martin Sebor [Thu, 29 Nov 2018 17:48:58 +0000 (17:48 +0000)]
PR c/88172 - attribute aligned of zero silently accepted but ignored

PR c/88172 - attribute aligned of zero silently accepted but ignored
PR testsuite/88208 - new test case c-c++-common/builtin-has-attribute-3.c in r266335 has multiple excess errors

gcc/ChangeLog:

PR c/88172
PR testsuite/88208
* doc/extend.texi (attribute constructor): Clarify.

gcc/c/ChangeLog:

PR c/88172
PR testsuite/88208
* c-decl.c (declspec_add_alignas): Adjust call to check_user_alignment.

gcc/c-family/ChangeLog:

PR c/88172
PR testsuite/88208
* c-attribs.c (common_handle_aligned_attribute): Silently avoid setting
alignments to values less than the target requires.
(has_attribute): For attribute aligned consider both the attribute
and the alignment bits.
* c-common.c (c_init_attributes): Optionally issue a warning for
zero alignment.

gcc/testsuite/ChangeLog:

PR c/88172
PR testsuite/88208
* gcc.dg/attr-aligned-2.c: New test.
* gcc.dg/builtin-has-attribute.c: Adjust.
* c-c++-common/builtin-has-attribute-2.c: Same.
* c-c++-common/builtin-has-attribute-3.c: Same.
* c-c++-common/builtin-has-attribute-4.c: Same.
* c-c++-common/builtin-has-attribute-5.c: New test.
* gcc.target/aarch64/attr-aligned.c: Same.
* gcc.target/i386/attr-aligned.c: Same.
* gcc.target/powerpc/attr-aligned.c: Same.
* gcc.target/sparc/attr-aligned.c: Same.

From-SVN: r266633

6 years agoFix thinko in transition to memop_ret type (PR middle-end/88246).
Martin Liska [Thu, 29 Nov 2018 17:17:39 +0000 (18:17 +0100)]
Fix thinko in transition to memop_ret type (PR middle-end/88246).

2018-11-29  Martin Liska  <mliska@suse.cz>

PR middle-end/88246
* builtins.c (expand_movstr): Fix thinko introduced
when switching to the new enum.

From-SVN: r266631

6 years agoAdd a new option -flive-patching={inline-only-static|inline-clone}
Qing Zhao [Thu, 29 Nov 2018 16:06:03 +0000 (16:06 +0000)]
Add a new option -flive-patching={inline-only-static|inline-clone}
to support live patching in GCC.

2018-11-29  qing zhao  <qing.zhao@oracle.com>

gcc/ChangeLog:

* cif-code.def (EXTERN_LIVE_ONLY_STATIC): New CIF code.
* common.opt: Add -flive-patching flag.
* doc/invoke.texi: Document -flive-patching.
* flag-types.h (enum live_patching_level): New enum.
* ipa-inline.c (can_inline_edge_p): Disable external functions from
inlining when flag_live_patching is LIVE_PATCHING_INLINE_ONLY_STATIC.
* opts.c (control_options_for_live_patching): New function.
(finish_options): Make flag_live_patching incompatible with flag_lto.
Control IPA optimizations based on different levels of
flag_live_patching.

gcc/testsuite/ChangeLog:

* gcc.dg/live-patching-1.c: New test.
* gcc.dg/live-patching-2.c: New test.
* gcc.dg/live-patching-3.c: New test.
* gcc.dg/tree-ssa/writeonly-3.c: New test.
* gcc.target/i386/ipa-stack-alignment-2.c: New test.

From-SVN: r266627

6 years agomatch.pd (sinh (atanh (x))): New simplification rules.
Giuliano Belinassi [Thu, 29 Nov 2018 15:32:30 +0000 (15:32 +0000)]
match.pd (sinh (atanh (x))): New simplification rules.

* match.pd (sinh (atanh (x))): New simplification rules.
(cosh (atanh (x))): Likewise.

* gcc.dg/sinhatanh-1.c: New test.
* gcc.dg/sinhatanh-2.c: New test.
* gcc.dg/sinhatanh-3.c: New test.

From-SVN: r266625

6 years agoOnly include bits/stl_algo.h for C++20.
Edward Smith-Rowland [Thu, 29 Nov 2018 15:17:17 +0000 (15:17 +0000)]
Only include bits/stl_algo.h for C++20.

2018-11-29  Edward Smith-Rowland  <3dw4rd@verizon.net>

Only include bits/stl_algo.h for C++20.
* include/std/deque: Only include bits/stl_algo.h for C++20.
* include/std/string: Ditto.
* include/std/vector: Ditto.

From-SVN: r266624

6 years agore PR target/54700 (Optimize away x<0 as mask argument of a blend.)
Jakub Jelinek [Thu, 29 Nov 2018 14:33:27 +0000 (15:33 +0100)]
re PR target/54700 (Optimize away x<0 as mask argument of a blend.)

PR target/54700
* config/i386/sse.md (ssebytemode): Add V16SI, V8SI and V4SI entries.
(ssefltmodesuffix, ssefltvecmode): New define_mode_attrs.
(*<sse4_1>_blendv<ssemodesuffix><avxsizesuffix>_lt,
*<sse4_1>_blendv<ssefltmodesuffix><avxsizesuffix>_ltint,
*<sse4_1_avx2>_pblendvb_lt): New define_insns.

* g++.target/i386/sse4_1-pr54700-1.C: New test.
* g++.target/i386/sse4_1-pr54700-2.C: New test.
* g++.target/i386/avx-pr54700-1.C: New test.
* g++.target/i386/avx-pr54700-2.C: New test.
* g++.target/i386/avx2-pr54700-1.C: New test.
* g++.target/i386/avx2-pr54700-2.C: New test.
* g++.target/i386/sse4_1-check.h: New file.
* g++.target/i386/avx-check.h: New file.
* g++.target/i386/avx2-check.h: New file.
* g++.target/i386/m128-check.h: New file.
* g++.target/i386/m256-check.h: New file.
* g++.target/i386/avx-os-support.h: New file.

From-SVN: r266621

6 years agore PR target/88152 (optimize SSE & AVX char compares with subsequent movmskb)
Jakub Jelinek [Thu, 29 Nov 2018 14:32:00 +0000 (15:32 +0100)]
re PR target/88152 (optimize SSE & AVX char compares with subsequent movmskb)

PR target/88152
* tree.h (build_uniform_cst, uniform_integer_cst_p): Declare.
* tree.c (build_uniform_cst, uniform_integer_cst_p): New functions.
* match.pd (define_predicates): Add uniform_integer_cst_p.
(cmp @0 INTEGER_CST@1, cmp (convert?@2 @0) INTEGER_CST@1): Adjust
so that it works also for vector comparisons with uniform constants
with INTEGER_CST element.

* g++.dg/tree-ssa/pr88152-1.C: New test.
* g++.dg/tree-ssa/pr88152-2.C: New test.

From-SVN: r266620

6 years agore PR target/88234 (UBsan and runtime error: signed integer overflow using unsigned...
Jakub Jelinek [Thu, 29 Nov 2018 14:23:21 +0000 (15:23 +0100)]
re PR target/88234 (UBsan and runtime error: signed integer overflow using unsigned vector)

PR target/88234
* config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): For
vec_add and vec_sub builtins, perform PLUS_EXPR or MINUS_EXPR
in unsigned_type_for instead of vector integral type where overflow
doesn't wrap.

* gcc.dg/ubsan/pr88234.c: New test.

From-SVN: r266619

6 years agoThere can be at most one .resolver clone per function
Michael Ploujnikov [Thu, 29 Nov 2018 14:09:50 +0000 (14:09 +0000)]
There can be at most one .resolver clone per function

2018-11-29  Michael Ploujnikov  <michael.ploujnikov@oracle.com>

There can be at most one .resolver clone per function
* config/rs6000/rs6000.c (make_resolver_func): Generate
resolver symbol with clone_function_name instead of
clone_function_name_numbered.

From-SVN: r266617

6 years agoFix erasure goofs.
Edward Smith-Rowland [Thu, 29 Nov 2018 13:43:55 +0000 (13:43 +0000)]
Fix erasure goofs.

2018-11-29  Edward Smith-Rowland  <3dw4rd@verizon.net>

Fix erasure goofs.
* include/experimental/deque: Make inline.
* include/std/deque: Include bits/stl_algo.h.
(erase, erase_if): Make inline.
* include/std/string: Include bits/stl_algo.h.
* include/std/unordered_set: Add erase, erase_if!
* include/std/vector: Include bits/stl_algo.h.
* testsuite/21_strings/basic_string/erasure.cc:
Add { dg-options "-std=gnu++2a" }.
* testsuite/23_containers/deque/erasure.cc: Ditto.
* testsuite/23_containers/forward_list/erasure.cc: Ditto.
* testsuite/23_containers/list/erasure.cc: Ditto.
* testsuite/23_containers/map/erasure.cc: Ditto.
* testsuite/23_containers/set/erasure.cc: Ditto.
* testsuite/23_containers/unordered_map/erasure.cc: Ditto.
* testsuite/23_containers/unordered_set/erasure.cc: Ditto.
* testsuite/23_containers/vector/erasure.cc: Ditto.

From-SVN: r266616

6 years agore PR tree-optimization/88243 (ice in vect_create_epilog_for_reduction, at tree-vect...
Richard Biener [Thu, 29 Nov 2018 13:33:59 +0000 (13:33 +0000)]
re PR tree-optimization/88243 (ice in vect_create_epilog_for_reduction, at tree-vect-loop.c:4689)

2018-11-29  Richard Biener  <rguenther@suse.de>

PR tree-optimization/88243
* tree-vect-patterns.c (vect_mark_pattern_stmts): Set the def
type of all pattern-sequence stmts to vect_internal_def.

* gcc.dg/torture/pr88243.c: New testcase.

From-SVN: r266615

6 years agoPR libstdc++/88119 use alignof in std::alignment_of, not __alignof__
Jonathan Wakely [Thu, 29 Nov 2018 12:32:57 +0000 (12:32 +0000)]
PR libstdc++/88119 use alignof in std::alignment_of, not __alignof__

Now that __alignof__ and alignof sometimes disagree it matters which one
we use. The standard says that std::alignment_of<T>::value equals
alignof(T), so we need to use that.

Change the only uses of alignment_of to use __alignof__ to avoid a
change in alignment.

PR libstdc++/88119
* include/ext/aligned_buffer.h (__aligned_membuf): Add comment.
(__aligned_buffer): Use __alignof__ instead of std::alignment_of.
* include/std/type_traits (alignment_of): Use alignof instead of
__alignof__.
* testsuite/20_util/alignment_of/value.cc: Fix test to check values
match alignof not __alignof__, as required by the standard.

From-SVN: r266613

6 years ago[PATCH] [Arm] Fix fpu configurations for Cortex-R7 and Cortex-R8
Andre Vieira [Thu, 29 Nov 2018 10:20:13 +0000 (10:20 +0000)]
[PATCH] [Arm] Fix fpu configurations for Cortex-R7 and Cortex-R8

gcc/ChangeLog:
2018-11-29  Andre Vieira  <andre.simoesdiasvieira@arm.com>

PR target/88224
* config/arm/arm-cpus.in (armv7-r): Add FP16conv configurations.
(cortex-r7, cortex-r8): Update default and add new configuration.
* doc/invoke.texi (armv7-r): Add two new vfp options.
(nofp.dp): Add cortex-r7 and cortex-r8 to the list of targets that
support this option.

From-SVN: r266612

6 years agore PR c++/87539 (internal compiler error when compiling project with Os optimization...
Jakub Jelinek [Thu, 29 Nov 2018 07:42:52 +0000 (08:42 +0100)]
re PR c++/87539 (internal compiler error when compiling project with Os optimization flag)

PR c++/87539
* g++.dg/cpp0x/pr87539.C: New test.

From-SVN: r266611

6 years ago[RS6000] PR11848 rs6000_emit_move long double split
Alan Modra [Thu, 29 Nov 2018 05:03:01 +0000 (15:33 +1030)]
[RS6000] PR11848 rs6000_emit_move long double split

This split is disabled for power7 and up, so we don't often see its
bad effects.  However, on a powerpc-linux compiler (which defaults
to PPC750 judging from rs6000/sysv4.h) we see

long double ld1 (void) { return 1.0L; }

compiled with -msoft-float -O2 -S resulting in

ld1:
li 3,0
li 4,0
mr 6,4
mr 5,3
li 4,0
lis 3,0x3ff0
blr

Things go awry in init-regs, with the TFmode reg being initialized to
zero on seeing the subreg from the split.  (And that initialization
itself is split by rs6000_emit_move!)  Later passes apparently don't
clean up the rubbish.

Since the split was added for Darwin (as the comment says), let's get
rid of it on other targets.

* config/rs6000/rs6000.c (rs6000_emit_move): Disable long
double split for targets other than Darwin.

From-SVN: r266610

6 years ago[RS6000] movdi_internal64 insn lengths
Alan Modra [Thu, 29 Nov 2018 05:01:05 +0000 (15:31 +1030)]
[RS6000] movdi_internal64 insn lengths

Fixes alternatives wi<-Oj (xxlxor), wi<-wM (xxlorc) and wv<-wS
(xxsltib+extend).

* config/rs6000/rs6000.md (movdi_internal64): Correct lengths.

From-SVN: r266609

6 years ago[RS6000] CONST_DOUBLE tidy
Alan Modra [Thu, 29 Nov 2018 04:59:19 +0000 (15:29 +1030)]
[RS6000] CONST_DOUBLE tidy

Once upon a time CONST_DOUBLE was used to hold large integer constants
that didn't fit into a CONST_INT.  Now that CONST_INT is always at
least 64 bits, and the rs6000 backend uses CONST_WIDE_INT for larger
integers, there is no need for old code dealing with integers in
CONST_DOUBLE.  The rs6000 backend also doesn't create DImode subregs
of TFmode CONST_DOUBLE, as once we did.  This patch cleans up a few
leftovers from the past.

* config/rs6000/predicates.md (easy_fp_constant): Remove code
dealing with integers in const_double.  Assert on unexpected
modes.  Delete superfluous ABI_V4 test.
* config/rs6000/rs6000.c (rs6000_emit_move): Comment fixes.
Don't call easy_fp_constant for Pmode.
(rs6000_hash_constant): Remove code dealing with integers in
const_double.
(rs6000_legitimate_constant_p): Likewise.
(output_toc): Formatting, use CONST_DOUBLE_P.

From-SVN: r266608

6 years ago[RS6000] "G" and "H" constraints
Alan Modra [Thu, 29 Nov 2018 04:58:08 +0000 (15:28 +1030)]
[RS6000] "G" and "H" constraints

The patch fixes two cases where the "G" and "H" constraints were used
incorrectly.  Their purpose is calculating insn lengths.  Thus it
never makes sense to put "GH" together or with "F" in an insn
alternative.

movdi_internal32 used "GHF" in an alternative so I replaced that with
"F", and added length attributes for the insn, which were missing.
There are some formatting changes too, to make alternatives line up
with attributes.

The FMOVE128 version of mov<mode>_softfloat also had "GHF" in an
alternative, so "GH" is dropped and "F" moved to a separate
alternative in order to get insn lengths correct.  Well by correct I
mean we need to choose the maximum insn length otherwise branches
might not reach.  Note the very large length for "F".  I think it
would be better to force soft-float long double constants to memory in
64-bit mode, but that's a patch for another day.

* config/rs6000/constraints.md (G, H): Comment on purpose of
constraint.  Correct mode comments and "G" mode test.
* config/rs6000/rs6000.md (movdi_internal32): Remove "GH" from
alternative handling "F".  Add length attr.  Formatting.
(mov<mode>_softfloat <FMOVE128>): Delete "GH" from
alternative, and move "F" to separate alternative.  Correct
insn lengths.

From-SVN: r266607

6 years ago[RS6000] Bogus easy_fp_constant call
Alan Modra [Thu, 29 Nov 2018 04:56:33 +0000 (15:26 +1030)]
[RS6000] Bogus easy_fp_constant call

easy_fp_constant accepts const_double, easy_vector_constant accepts
const_vector.  Calling one from the other therefore will always return
false.  I believe the zero_constant call in easy_vector_constant will
cover the 0.0 case of easy_fp_constant.

* config/rs6000/predicates.md (easy_vector_constant): Don't call
easy_fp_constant.

From-SVN: r266606

6 years ago[RS6000] inline plt call sequences
Alan Modra [Thu, 29 Nov 2018 04:53:49 +0000 (15:23 +1030)]
[RS6000] inline plt call sequences

Finally, the point of the previous patches in this series, support for
inline PLT calls, keyed off -fno-plt.  This emits code using new
relocations that tie all insns in the sequence together, so that the
linker can edit the sequence back to a direct call should the call
target turn out to be local.  An example of ELFv2 code to call puts is
as follows:

     .reloc .,R_PPC64_PLTSEQ,puts
        std 2,24(1)
     .reloc .,R_PPC64_PLT16_HA,puts
        addis 12,2,0
     .reloc .,R_PPC64_PLT16_LO_DS,puts
        ld 12,0(12)
     .reloc .,R_PPC64_PLTSEQ,puts
        mtctr 12
     .reloc .,R_PPC64_PLTCALL,puts
        bctrl
        ld 2,24(1)

"addis 12,2,puts@plt@ha" and "ld 12,puts@plt@l(12)" are also supported
by the assembler.  gcc instead uses the explicit R_PPC64_PLT16_HA and
R_PPC64_PLT16_LO_DS relocs because when the call is to __tls_get_addr
an extra reloc is emitted at every place where one is shown above, to
specify the __tls_get_addr arg.  The linker expects the extra reloc to
come first.  .reloc enforces that ordering.

The patch also changes code emitted for longcalls if the assembler
supports the new marker relocs, so that these too can be edited.  One
side effect of longcalls using PLT16 relocs is that they can now be
resolved lazily by ld.so.

I don't support lazy inline PLT calls for ELFv1, because ELFv1 would
need barriers to reliably load both the function address and toc
pointer from the PLT.  ELFv1 -fno-plt uses the longcall sequence
instead, which isn't edited by GNU ld.

* config.in (HAVE_AS_PLTSEQ): Add.
* config/rs6000/predicates.md (indirect_call_operand): New.
* config/rs6000/rs6000-protos.h (rs6000_pltseq_template),
(rs6000_sibcall_sysv): Declare.
* config/rs6000/rs6000.c (init_cumulative_args): Set cookie
CALL_LONG for -fno-plt.
(print_operand <T, z, 0>): Handle UNSPEC_PLTSEQ.
(rs6000_indirect_call_template_1): Emit .reloc directives for
UNSPEC_PLTSEQ calls.
(rs6000_pltseq_template): New function.
(rs6000_longcall_ref): Add arg parameter.  Use PLT16 insns if
relocs supported by assembler.  Move SYMBOL_REF test to callers.
(rs6000_call_aix): Adjust rs6000_longcall_ref call.  Package
insns in UNSPEC_PLTSEQ, preserving original func_desc.
(rs6000_call_sysv): Likewise.
(rs6000_sibcall_sysv): New function.
* config/rs6000/rs6000.h (HAVE_AS_PLTSEQ): Provide default.
* config/rs6000/rs6000.md (UNSPEC_PLTSEQ, UNSPEC_PLT16_HA,
UNSPEC_PLT16_LO): New.
(pltseq_tocsave, pltseq_plt16_ha, pltseq_plt16_lo, pltseq_mtctr): New.
(call_indirect_nonlocal_sysv): Don't differentiate zero from non-zero
cookie in constraints.  Test explicitly for flags in length attr.
Handle unspec operand 1.
(call_value_indirect_nonlocal_sysv): Likewise.
(call_indirect_aix, call_value_indirect_aix): Handle unspec operand 1.
(call_indirect_elfv2, call_value_indirect_elfv2): Likewise.
(sibcall, sibcall_value): Use rs6000_sibcall_sysv.
(sibcall_indirect_nonlocal_sysv): New pattern.
(sibcall_value_indirect_nonlocal_sysv): Likewise.
(sibcall_nonlocal_sysv, sibcall_value_nonlocal_sysv): Remove indirect
call alternatives.
* configure.ac: Check for gas plt sequence marker support.
* configure: Regenerate.

From-SVN: r266605

6 years ago[RS6000] Use standard call patterns for __tls_get_addr calls
Alan Modra [Thu, 29 Nov 2018 04:47:51 +0000 (15:17 +1030)]
[RS6000] Use standard call patterns for __tls_get_addr calls

The current code handling __tls_get_addr calls for powerpc*-linux
generates a call then overwrites the call insn with a special
tls_{gd,ld}_{aix,sysv} pattern.  It's done that way to support
!TARGET_TLS_MARKERS, where the arg setup insns need to be emitted
immediately before the branch and link.  When TARGET_TLS_MARKERS, the
arg setup insns are split from the actual call, but we then have a
non-standard call pattern that needs to be carried through to output.

This patch changes that scheme, to instead use the standard call
patterns for __tls_get_addr calls, except for the now rare
!TARGET_TLS_MARKERS case.  Doing it this way should be better for
maintenance as the !TARGET_TLS_MARKERS code can eventually disappear.
It also makes it possible to support longcalls (and in following
patches, inline plt calls) for __tls_get_addr without introducing yet
more special call patterns.

__tls_get_addr calls do however need to be different to standard
calls, because when TARGET_TLS_MARKERS the calls are decorated with an
argument specifier, eg. "bl __tls_get_addr(thread_var@tlsgd)" that
causes a reloc to be emitted by the assembler tying the call to its
arg setup insns.  I chose to smuggle the arg in the currently unused
stack size rtl.

I've also introduced rs6000_call_sysv to generate rtl for sysv calls,
as rs6000_call_aix does for aix and elfv2 calls.  This allows
rs6000_longcall_ref to be local to rs6000.c since the calls in the
expanders never did anything for darwin.

* config/rs6000/predicates.md (unspec_tls): New.
* config/rs6000/rs6000-protos.h (rs6000_call_template),
(rs6000_sibcall_template): Update prototype.
(rs6000_longcall_ref): Delete.
(rs6000_call_sysv): Declare.
* config/rs6000/rs6000.c (edit_tls_call_insn): New function.
(global_tlsarg): New variable.
(rs6000_legitimize_tls_address): Rewrite __tls_get_addr call
handling.
(print_operand): Extract UNSPEC_TLSGD address operand.
(rs6000_call_template, rs6000_sibcall_template): Remove arg
parameter, extract from second call operand instead.
(rs6000_longcall_ref): Make static, localize vars.
(rs6000_call_aix): Rename parameter to reflect new usage.  Take
tlsarg from global_tlsarg.  Don't create unused rtl or nop insns.
(rs6000_sibcall_aix): Rename parameter to reflect new usage.  Take
tlsarg from global_tlsarg.
(rs6000_call_sysv): New function.
* config/rs6000/rs6000.md: Adjust rs6000_call_template and
rs6000_sibcall_template throughout.
(tls_gd_aix, tls_gd_sysv, tls_gd_call_aix, tls_gd_call_sysv): Delete.
(tls_ld_aix, tls_ld_sysv, tls_ld_call_aix, tls_ld_call_sysv): Delete.
(tls_gdld_nomark): New insn.
(tls_gd): Swap operand order.  Simplify mode selection.
(tls_gd_high, tls_gd_low): Swap operand order.
(tls_ld): Remove const_int 0 vector element from UNSPEC_TLSLD.
Simplify mode selection.
(tls_ld_high, tls_ld_low): Similarly adjust UNSPEC_TLSLD.
(call, call_value): Don't assert for second call operand.
Use rs6000_call_sysv.

From-SVN: r266604

6 years ago[RS6000] Remove constraints on call rounded_stack_size_rtx arg
Alan Modra [Thu, 29 Nov 2018 04:46:21 +0000 (15:16 +1030)]
[RS6000] Remove constraints on call rounded_stack_size_rtx arg

This call arg is unused on rs6000.

* config/rs6000/darwin.md (call_indirect_nonlocal_darwin64),
(call_nonlocal_darwin64, call_value_indirect_nonlocal_darwin64),
(call_value_nonlocal_darwin64): Remove constraints from second call
arg, the rounded_stack_size_rtx arg.
* config/rs6000/rs6000.md (tls_gd_aix, tls_gd_sysv, tls_gd_call_aix),
(tls_gd_call_sysv, tls_ld_aix, tls_ld_sysv, tls_ld_call_aix),
(tls_ld_call_sysv, call_local32, call_local64, call_value_local32),
(call_value_local64, call_indirect_nonlocal_sysv),
(call_nonlocal_sysv, call_nonlocal_sysv_secure),
(call_value_indirect_nonlocal_sysv, call_value_nonlocal_sysv),
(call_value_nonlocal_sysv_secure, call_local_aix),
(call_value_local_aix, call_nonlocal_aix, call_value_nonlocal_aix),
(call_indirect_aix, call_value_indirect_aix, call_indirect_elfv2),
(call_value_indirect_elfv2, sibcall_local32, sibcall_local64),
(sibcall_value_local32, sibcall_value_local64, sibcall_aix),
(sibcall_value_aix): Likewise.

From-SVN: r266603

6 years ago[RS6000] Replace TLSmode with P, and correct tls call mems
Alan Modra [Thu, 29 Nov 2018 04:45:00 +0000 (15:15 +1030)]
[RS6000] Replace TLSmode with P, and correct tls call mems

There is really no need to define a TLSmode mode iterator that is
identical (since !TARGET_64BIT == TARGET_32BIT) to the much used P
mode iterator.  It's nonsense to think we might ever want to support
32-bit TLS on 64-bit or vice versa!  The patch also fixes a minor
error in the call mems.  All other direct calls use (call (mem:SI ..)).

* config/rs6000/rs6000.md (TLSmode): Delete mode iterator.  Replace
with P throughout except for call mems which should use SI.
(tls_abi_suffix, tls_sysv_suffix, tls_insn_suffix): Delete mode
attributes.  Replace with bits, mode and ptrload respectively.

From-SVN: r266602

6 years ago[RS6000] rs6000_indirect_call_template
Alan Modra [Thu, 29 Nov 2018 04:43:21 +0000 (15:13 +1030)]
[RS6000] rs6000_indirect_call_template

Like the last patch for external calls, now handle most assembly code
for indirect calls in one place.  The patch also merges some insns,
correcting some !rs6000_speculate_indirect_jumps cases branching to
LR, which don't require a speculation barrier.

* config/rs6000/rs6000-protos.h (rs6000_indirect_call_template),
(rs6000_indirect_sibcall_template): Declare.
* config/rs6000/rs6000.c (rs6000_indirect_call_template_1),
(rs6000_indirect_call_template, rs6000_indirect_sibcall_template):
New functions.
* config/rs6000/rs6000.md (call_indirect_nonlocal_sysv),
(call_value_indirect_nonlocal_sysv, sibcall_nonlocal_sysv),
(call_indirect_aix, call_value_indirect_aix): Use
rs6000_indirect_call_template and rs6000_indirect_sibcall_template.
call_indirect_elfv2, call_value_indirect_elfv2): Likewise, and
handle both speculation and non-speculation cases.
(call_indirect_aix_nospec, call_value_indirect_aix_nospec): Delete.
(call_indirect_elfv2_nospec, call_value_indirect_elfv2_nospec): Delete.

From-SVN: r266601

6 years ago[RS6000] rs6000_call_template for external call insn assembly output
Alan Modra [Thu, 29 Nov 2018 04:41:06 +0000 (15:11 +1030)]
[RS6000] rs6000_call_template for external call insn assembly output

This is a first step in tidying rs6000 call patterns, in preparation
to support inline plt calls.

* config/rs6000/rs6000-protos.h (rs6000_call_template): Declare.
(rs6000_sibcall_template): Declare.
(macho_call_template): Rename from output_call.
* config/rs6000/rs6000.c (rs6000_call_template_1): New function.
(rs6000_call_template, rs6000_sibcall_template): Likewise.
(macho_call_template): Rename from output_call.
* config/rs6000/rs6000.md (tls_gd_aix, tls_gd_sysv),
(tls_gd_call_aix, tls_gd_call_sysv, tls_ld_aix, tls_ld_sysv),
(tls_ld_call_aix, tls_ld_call_sysv, call_nonlocal_sysv),
(call_nonlocal_sysv_secure, call_value_nonlocal_sysv),
(call_value_nonlocal_sysv_secure, call_nonlocal_aix),
(call_value_nonlocal_aix): Use rs6000_call_template and update
occurrences of output_call to macho_call_template.
(sibcall_nonlocal_sysv, sibcall_value_nonlocal_sysv, sibcall_aix),
(sibcall_value_aix): Use rs6000_sibcall_template.

From-SVN: r266600

6 years agors6000-string.c (expand_block_clear): Change how we determine if unaligned vsx is ok.
Aaron Sawdey [Thu, 29 Nov 2018 03:56:14 +0000 (03:56 +0000)]
rs6000-string.c (expand_block_clear): Change how we determine if unaligned vsx is ok.

2018-11-28  Aaron Sawdey  <acsawdey@linux.ibm.com>

* config/rs6000/rs6000-string.c (expand_block_clear): Change how
we determine if unaligned vsx is ok.

From-SVN: r266599

6 years agoPR libstdc++/86910 fix filesystem::create_directories
Jonathan Wakely [Thu, 29 Nov 2018 00:39:37 +0000 (00:39 +0000)]
PR libstdc++/86910 fix filesystem::create_directories

Implement the proposed semantics from P1164R0, which reverts the changes
of LWG 2935. This means that failure to create a directory because a
non-directory already exists with that name will be reported as an
error.

While rewriting the function, also fix PR 87846, which is a result of
the C++17 changes to how a trailing slash on a path affects the last
component of a path.

PR libstdc++/86910
PR libstdc++/87846
* src/filesystem/ops.cc (experimental::create_directories): Report
an error when the path resolves to an existing non-directory (P1164).
* src/filesystem/std-ops.cc (create_directories): Likewise. Handle
empty filenames due to trailing slashes.
* testsuite/27_io/filesystem/operations/create_directories.cc: Test
when some component of the path exists and is not a directory. Test
trailing slashes.
* testsuite/experimental/filesystem/operations/create_directories.cc:
Likewise.

From-SVN: r266598

6 years agoDaily bump.
GCC Administrator [Thu, 29 Nov 2018 00:16:15 +0000 (00:16 +0000)]
Daily bump.

From-SVN: r266597

6 years agoPR c/88065 - ICE in -Wsizeof-pointer-memaccess on an invalid strncpy
Martin Sebor [Wed, 28 Nov 2018 23:04:09 +0000 (23:04 +0000)]
PR c/88065 - ICE in -Wsizeof-pointer-memaccess on an invalid strncpy

PR c/88065 - ICE in -Wsizeof-pointer-memaccess on an invalid strncpy
PR c/87297 - ICE on strncpy with an undeclared argument

gcc/c-family/ChangeLog:

PR c/88065
PR c/87297
* c-warn.c (sizeof_pointer_memaccess_warning): Bail if source
or destination is an error.

gcc/testsuite/ChangeLog:

PR c/88065
PR c/87297
* c-c++-common/Wsizeof-pointer-memaccess4.c: New test.

From-SVN: r266594

6 years agolibphobos: Merge common version blocks using arch_any conditions
Iain Buclaw [Wed, 28 Nov 2018 21:53:06 +0000 (21:53 +0000)]
libphobos: Merge common version blocks using arch_any conditions

This sets a precedence in upstream for merging architecture agnostic
C bindings into one block, rather than separate duplicated blocks.

A nice side-effect is it almost completes the C bindings for
s390-linux-gnu and sparc-linux-gnu, and fixes a bug on MIPS32 where
O_SYNC had the wrong value.

Backported from upstream druntime master.

Reviewed-on: https://github.com/dlang/druntime/pull/2357

From-SVN: r266593

6 years agoImplement P1094R2, Nested inline namespaces.
Marek Polacek [Wed, 28 Nov 2018 21:39:42 +0000 (21:39 +0000)]
Implement P1094R2, Nested inline namespaces.

* parser.c (cp_parser_namespace_definition): Parse the optional inline
keyword in a nested-namespace-definition.  Adjust push_namespace call.
Formatting fix.

* g++.dg/cpp2a/nested-inline-ns1.C: New test.
* g++.dg/cpp2a/nested-inline-ns2.C: New test.

From-SVN: r266592

6 years ago[PR c++/87531] operator= lookup in templates
Nathan Sidwell [Wed, 28 Nov 2018 21:25:06 +0000 (21:25 +0000)]
[PR c++/87531] operator= lookup in templates

https://gcc.gnu.org/ml/gcc-patches/2018-11/msg02301.html
PR c++/87531
* class.c (finish_struct): In a template, add artificial using
decl for operator=.

* g++.dg/lookup/pr87531.C: New.

From-SVN: r266590

6 years agopredict.c (determine_unlikely_bbs): Forward declare...
Jan Hubicka [Wed, 28 Nov 2018 20:48:53 +0000 (21:48 +0100)]
predict.c (determine_unlikely_bbs): Forward declare...

* predict.c (determine_unlikely_bbs): Forward declare; also determine
edges that are always known to be taken because it is only likely
edge out of given BB.
(tree_estimate_probability): Call before profile guessing to get bit
of extra precision.

* gcc.dg/predict-13.c: Update template.
* gcc.dg/predict-13b.c: New testcase.
* gcc.dg/predict-22.c: New testcase.
* gcc.dg/tree-ssa/ipa-split-4.c: Change abort to other function to
get sane profile.

From-SVN: r266587

6 years ago* lto.c (lto_read_decls): Fix handling of INTEGER_CST.
Jan Hubicka [Wed, 28 Nov 2018 20:36:13 +0000 (21:36 +0100)]
* lto.c (lto_read_decls): Fix handling of INTEGER_CST.

From-SVN: r266586

6 years agotree-ssa-ifcombine.c (update_profile_after_ifcombine): Handle profile_probability...
Jan Hubicka [Wed, 28 Nov 2018 20:34:06 +0000 (21:34 +0100)]
tree-ssa-ifcombine.c (update_profile_after_ifcombine): Handle profile_probability::always better.

* tree-ssa-ifcombine.c (update_profile_after_ifcombine): Handle
profile_probability::always better.

From-SVN: r266585

6 years agoprofile-count.h (profile_count::split): Give better result when splitting profile_pro...
Jan Hubicka [Wed, 28 Nov 2018 20:29:24 +0000 (21:29 +0100)]
profile-count.h (profile_count::split): Give better result when splitting profile_probability::always.

* profile-count.h (profile_count::split): Give better result when
splitting profile_probability::always.

From-SVN: r266584

6 years agoexcept.c (do_allocate_exception): Annotate __cxa_allocate_exception as COLD.
Jan Hubicka [Wed, 28 Nov 2018 20:25:08 +0000 (21:25 +0100)]
except.c (do_allocate_exception): Annotate __cxa_allocate_exception as COLD.

* except.c (do_allocate_exception): Annotate __cxa_allocate_exception
as COLD.

From-SVN: r266583

6 years agore PR target/88207 (gcc.target/i386/pr22076.c etc. FAIL)
Vladimir Makarov [Wed, 28 Nov 2018 20:08:03 +0000 (20:08 +0000)]
re PR target/88207 (gcc.target/i386/pr22076.c etc. FAIL)

2018-11-28  Vladimir Makarov  <vmakarov@redhat.com>

PR target/88207
* ira-costs.c (scan_one_insn): Process subregs when updating costs
for pseudos and allocnos from insn.

From-SVN: r266582

6 years agoPR c++/88222 - ICE with bit-field with invalid type.
Marek Polacek [Wed, 28 Nov 2018 20:03:06 +0000 (20:03 +0000)]
PR c++/88222 - ICE with bit-field with invalid type.

* decl.c (grokdeclarator): Check if declarator is null.

* g++.dg/ext/flexary31.C: New test.

From-SVN: r266581

6 years ago* gcc.dg/recip_sqrt_mult_[12345]: Do not add -fcompare-debug on AIX.
David Edelsohn [Wed, 28 Nov 2018 18:33:46 +0000 (18:33 +0000)]
* gcc.dg/recip_sqrt_mult_[12345]: Do not add -fcompare-debug on AIX.

From-SVN: r266577

6 years agopr86900.C: XFAIL AIX.
David Edelsohn [Wed, 28 Nov 2018 18:30:41 +0000 (18:30 +0000)]
pr86900.C: XFAIL AIX.

        * g++.dg/debug/dwarf2/pr86900.C: XFAIL AIX.
        * g++.dg/opt/pr83084.C: XFAIL AIX.

From-SVN: r266576