* sel-sched-ir.c (has_dependence_note_mem_dep): Take into account the
correct producer for the insn.
(tidy_control_flow): Fixup seqnos in case of debug insns.
* gcc.dg/pr80463.c: New test.
* g++.dg/pr80463.C: Likewise.
* gcc.dg/pr83972.c: Likewise.
re PR rtl-optimization/83530 (ICE in reset_sched_cycles_in_current_ebb, at sel-sched.c:7150)
PR rtl-optimization/83530
* sel-sched.c (force_next_insn): New global variable.
(remove_insn_for_debug): When force_next_insn is true, also leave only
next insn in the ready list.
(sel_sched_region): When the region wasn't scheduled, make another pass
over it with force_next_insn set to 1.
Kito Cheng [Sun, 8 Apr 2018 08:31:52 +0000 (08:31 +0000)]
[NDS32] Implement n8 pipeline.
gcc/
* config.gcc (nds32*-*-*): Check that n6/n8/s8 are valid to --with-cpu.
* config/nds32/nds32-n8.md: New file.
* config/nds32/nds32-opts.h (nds32_cpu_type): Add CPU_N6 and CPU_N8.
* config/nds32/nds32-pipelines-auxiliary.c: Implementation for n8
pipeline.
* config/nds32/nds32-protos.h: More declarations for n8 pipeline.
* config/nds32/nds32-utils.c: More implementations for n8 pipeline.
* config/nds32/nds32.md (pipeline_model): Add n8.
* config/nds32/nds32.opt (mcpu): Support n8 pipeline cpus.
* config/nds32/pipelines.md: Include n8 settings.
Kito Cheng [Sun, 8 Apr 2018 08:12:19 +0000 (08:12 +0000)]
[NDS32] Implment n9 pipeline.
gcc/
* config.gcc (nds32*): Add nds32-utils.o into extra_objs.
* config/nds32/nds32-n9-2r1w.md: New file.
* config/nds32/nds32-n9-3r2w.md: New file.
* config/nds32/nds32-opts.h (nds32_cpu_type, nds32_mul_type,
nds32_register_ports): New or modify for cpu n9.
* config/nds32/nds32-pipelines-auxiliary.c: Implementation for n9
pipeline.
* config/nds32/nds32-protos.h: More declarations for n9 pipeline.
* config/nds32/nds32-utils.c: New file.
* config/nds32/nds32.h (TARGET_PIPELINE_N9, TARGET_PIPELINE_SIMPLE,
TARGET_MUL_SLOW): Define.
* config/nds32/nds32.md (pipeline_model): New attribute.
* config/nds32/nds32.opt (mcpu, mconfig-mul, mconfig-register-ports):
New options that support cpu n9.
* config/nds32/pipelines.md: Include n9 settings.
* config/nds32/t-nds32 (nds32-utils.o): Add dependency.
Thomas Koenig [Sat, 7 Apr 2018 23:52:03 +0000 (23:52 +0000)]
re PR middle-end/82976 (Error: non-trivial conversion at assignment since r254526)
2018-04-07 Thomas Koenig <tkoenig@gcc.gnu.org>
Andrew Pinski <pinsika@gcc.gnu.org>
PR middle-end/82976
* match.pd: Use constant_boolean_node of correct type instead of
boolean_true_node or boolean_false_node for simplifying
pointer comparisons to zero.
2018-04-07 Thomas Koenig <tkoenig@gcc.gnu.org>
PR middle-end/82976
* gfortran.dg/realloc_on_assign_16a.f90: New test.
Co-Authored-By: Andrew Pinski <pinskia@gcc.gnu.org>
From-SVN: r259212
Jakub Jelinek [Sat, 7 Apr 2018 07:20:42 +0000 (09:20 +0200)]
re PR tree-optimization/85257 (wrong code with -O -fno-tree-ccp and reading zeroed vector member)
PR tree-optimization/85257
* fold-const.c (native_encode_vector): If not all elts could fit
and off is -1, return 0 rather than offset.
* tree-ssa-sccvn.c (vn_reference_lookup_3): Pass
(offseti - offset2) / BITS_PER_UNIT as 4th argument to
native_encode_expr. Verify len * BITS_PER_UNIT >= maxsizei. Don't
adjust buffer in native_interpret_expr call.
Jason Merrill [Fri, 6 Apr 2018 18:09:53 +0000 (14:09 -0400)]
PR c++/85214 - ICE with alias, generic lambda, constexpr if.
Here, since the condition for the constexpr if depends on the type of 'j',
it's still dependent when we are partially instantiating the inner lambda,
so we need to defer instantiating the constexpr if. When we instantiated
the inner lambda, we tried to substitute into the typename, which failed
because we didn't have a declaration of 'i' available.
Fixed by teaching extract_locals_r to capture local typedefs such as 'ar';
if we have the typedef handy, we don't need to substitute into its
definition.
* pt.c (extract_locals_r): Remember local typedefs.
David Malcolm [Fri, 6 Apr 2018 17:36:33 +0000 (17:36 +0000)]
C++: more std header hints; filter on C++ dialect (PR c++/84269)
This patch adds more suggestions as per:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84269#c10
some of which need C++14 and C++17, and some of which use headers that
exist in earlier standards.
For example, <memory> exists in C++98, but if the user attempts to
use std::make_shared with -std=c++98, they are suggested to include
<memory>, even if they've already included it.
This patch adds the missing names, and fixes the nonsensical suggestions
by detecting if the name isn't available yet, based on the user's
dialect, and reporting things more intelligently:
t.cc: In function 'void test_make_shared()':
t.cc:5:8: error: 'make_shared' is not a member of 'std'
std::make_shared<int>();
^~~~~~~~~~~
t.cc:5:8: note: 'std::make_shared' is only available from C++11 onwards
gcc/cp/ChangeLog:
PR c++/84269
* name-lookup.c (struct std_name_hint): Move out of
get_std_name_hint; add field "min_dialect".
(get_std_name_hint): Add min_dialect values to all initializers.
Add <any>, <atomic>, <bitset>, <condition_variable>, <functional>,
<future>, <istream>, <iterator>, <ostream>, <mutex>, <optional>,
<shared_mutex>, <string_view>, <thread>, and <variant>.
Add fstream, ifstream, and ofstream to <fstream>.
Add istringstream, ostringstream, and stringstream to <sstream>.
Add basic_string to <string>.
Add tuple_element and tuple_size to <tuple>.
Add declval to <utility>.
Fix ordering of <queue> and <tuple>.
Return a std_name_hint, rather than a const char *.
(get_cxx_dialect_name): New function.
(maybe_suggest_missing_std_header): Detect names that aren't yet
available in the current dialect, and instead of suggesting a
missing #include, warn about the dialect.
gcc/testsuite/ChangeLog:
PR c++/84269
* g++.dg/lookup/missing-std-include-6.C: Move std::array and
std::tuple here since they need C++11.
* g++.dg/lookup/missing-std-include-8.C: New test.
* g++.dg/lookup/missing-std-include.C: Move std::array and
std::tuple test to missing-std-include-6.C to avoid failures
with C++98.
Jakub Jelinek [Fri, 6 Apr 2018 17:28:02 +0000 (19:28 +0200)]
re PR rtl-optimization/84872 (ICE in create_preheader, at cfgloopmanip.c:1536)
PR rtl-optimization/84872
* cfgloopmanip.c (create_preheader): Use make_forwarder_block even if
nentry == 1 when CP_FALLTHRU_PREHEADERS and single_entry is
EDGE_CROSSING edge.
David Malcolm [Fri, 6 Apr 2018 15:46:04 +0000 (15:46 +0000)]
C++: suggest missing headers for implicit use of "std" (PR c++/85021)
We provide fix-it hints for the most common "std" names when an explicit
"std::" prefix is present, however we don't yet provide fix-it hints for
this implicit case:
using namespace std;
void f() { cout << "test"; }
for which we emit:
t.cc: In function 'void f()':
t.cc:2:13: error: 'cout' was not declared in this scope
void f() { cout << "test"; }
^~~~
This patch detects if a "using namespace std;" directive is present
in the current namespace, and if so, offers a suggestion for
unrecognized names that are in our list of common "std" names:
t.cc: In function 'void f()':
t.cc:2:13: error: 'cout' was not declared in this scope
void f() { cout << "test"; }
^~~~
t.cc:2:13: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
+#include <iostream>
using namespace std;
void f() { cout << "test"; }
^~~~
gcc/cp/ChangeLog:
PR c++/85021
* name-lookup.c (using_directives_contain_std_p): New function.
(has_using_namespace_std_directive_p): New function.
(suggest_alternatives_for): Simplify if/else logic using early
returns. If no candidates were found, and there's a
"using namespace std;" directive, call
maybe_suggest_missing_std_header.
(maybe_suggest_missing_header): Split later part of the function
into..
(maybe_suggest_missing_std_header): New.
gcc/testsuite/ChangeLog:
PR c++/85021
* g++.dg/lookup/missing-std-include-7.C: New test.
Richard Biener [Fri, 6 Apr 2018 11:47:18 +0000 (11:47 +0000)]
re PR tree-optimization/85244 (Bad optimisation with flexible array member (may be related to -ftree-dominator-opts))
2018-04-06 Richard Biener <rguenther@suse.de>
PR middle-end/85244
* tree-dfa.c (get_ref_base_and_extent): Reset seen_variable_array_ref
after seeing a component reference with an adjacent field. Treat
refs to arrays at struct end of external decls similar to
refs to unconstrained commons.
* gcc.dg/torture/pr85244-1.c: New testcase.
* gcc.dg/torture/pr85244-2.c: Likewise.
Richard Biener [Fri, 6 Apr 2018 08:30:52 +0000 (08:30 +0000)]
re PR rtl-optimization/85180 (Infinite loop in RTL DSE optimizer)
2018-04-06 Richard Biener <rguenther@suse.de>
PR middle-end/85180
* alias.c (find_base_term): New wrapper around find_base_term
unwinding CSELIB_VAL_PTR changes.
(find_base_term): Do not restore CSELIB_VAL_PTR during the
recursion.
Andreas Krebbel [Fri, 6 Apr 2018 07:46:30 +0000 (07:46 +0000)]
IBM Z: Fix vcond-shift testcase.
gcc/testsuite/ChangeLog:
2018-04-06 Andreas Krebbel <krebbel@linux.vnet.ibm.com>
* gcc.target/s390/vector/vcond-shift.c: Use the proper conditions
to trigger the optimization. Do some cleanup and function
renaming. Add more test functions.
Andreas Krebbel [Fri, 6 Apr 2018 07:45:42 +0000 (07:45 +0000)]
IBM Z: Use the dedicated NOP instructions for "nop"
We still use lr r0,r0 as a NOP instruction although we have some kind
of dedicated NOP instruction (nopr) which maps to a "branch never".
As a side-effect this fixes testcases scanning for NOPs
e.g. patchable_function_entry-*.
As another side-effect this makes it difficult to distingiush NOPs
generated for hotpatching from NOPs added when using -O0 to attach
location information to it. Hence I had to make sure that the hotpatch
testcases get skipped when compiling without optimization.
gcc/ChangeLog:
2018-04-06 Andreas Krebbel <krebbel@linux.vnet.ibm.com>
* config/s390/s390.c (s390_z10_optimize_cmp): Expand dedicated NOP
instructions.
* config/s390/s390.md (UNSPECV_NOP_LR_0, UNSPECV_NOP_LR_1): New
constant definitions.
("nop"): lr 0,0 -> nopr r0
("nop_lr0", "nop_lr1"): New insn definitions.
gcc/testsuite/ChangeLog:
2018-04-06 Andreas Krebbel <krebbel@linux.vnet.ibm.com>
gcc/
* config.gcc (nds32*-*-*): Add v2j v3f v3s checking.
(nds32*-*-*): Add float and fpu_config into supported_defaults.
* common/config/nds32/nds32-common.c (TARGET_DEFAULT_TARGET_FLAGS):
Include TARGET_DEFAULT_FPU_ISA and TARGET_DEFAULT_FPU_FMA.
* config/nds32/constants.md (unspec_element): Add UNSPEC_COPYSIGN,
UNSPEC_FCPYNSD, UNSPEC_FCPYNSS, UNSPEC_FCPYSD and UNSPEC_FCPYSS.
* config/nds32/constraints.md: New constraints and checking for hard
float configuration.
* config/nds32/iterators.md: New mode iterator and attribute for hard
float configuration.
* config/nds32/nds32-doubleword.md: Use hard float alternatives and
patterns.
* config/nds32/nds32-fpu.md: New file.
* config/nds32/nds32-md-auxiliary.c: New functions and checkings to
deal with hard float code generation.
* config/nds32/nds32-opts.h (nds32_arch_type): Add ARCH_V3F and
ARCH_V3S.
(abi_type, float_reg_number): New enum type.
* config/nds32/nds32-predicates.c: New predicates for hard float.
* config/nds32/nds32-protos.h: Declare functions for hard float.
* config/nds32/nds32.c: Implementation for hard float configuration.
* config/nds32/nds32.h: Definitions for hard float configuration.
* config/nds32/nds32.md: Include hard float machine description and
modify patterns for hard float configuration.
* config/nds32/nds32.opt: New options for hard float configuration.
* config/nds32/predicates.md: New predicates for hard float
configuration.
Jakub Jelinek [Thu, 5 Apr 2018 21:29:51 +0000 (23:29 +0200)]
re PR c++/85208 (ICE with #pragma weak and structured binding)
PR c++/85208
* decl.c (start_decl): For DECL_DECOMPOSITION_P decls, don't call
maybe_apply_pragma_weak here...
(cp_maybe_mangle_decomp): ... but call it here instead.
H.J. Lu [Thu, 5 Apr 2018 17:49:39 +0000 (17:49 +0000)]
Use dlsym to check if libdl is needed for plugin
config/plugins.m4 has
if test "$plugins" = "yes"; then
AC_SEARCH_LIBS([dlopen], [dl])
fi
Plugin uses dlsym, but libasan.so only intercepts dlopen, not dlsym:
[hjl@gnu-tools-1 binutils-text]$ nm -D /lib64/libasan.so.4| grep " dl" 0000000000038580 W dlclose
U dl_iterate_phdr 000000000004dc50 W dlopen
U dlsym
U dlvsym
[hjl@gnu-tools-1 binutils-text]$
Testing dlopen for libdl leads to false negative when -fsanitize=address
is used. It results in link failure:
../bfd/.libs/libbfd.a(plugin.o): undefined reference to symbol 'dlsym@@GLIBC_2.16'
dlsym should be used to check if libdl is needed for plugin.
PR gas/22318
* plugins.m4 (AC_PLUGINS): Use dlsym to check if libdl is needed.
[PR c++/84979] reject auto in explicit tmpl args for tmpl-fn
With concepts, we accept auto in explicit template arguments, but we
should only accept them for template classes. Passing them to
template functions or variables is not allowed. So, reject it, at
parse time if possible, at specialization time otherwise.
for gcc/cp/ChangeLog
PR c++/84979
* pt.c (check_auto_in_tmpl_args): New.
(tsubst_qualified_id): Use it to reject template args
referencing auto for non-type templates.
* parser.c (cp_parser_template_id): Likewise.
* cp-tree.h (check_auto_in_tmpl_args): Declare.
* typeck2.c (build_functional_cast): Report correct location
for invalid use of auto.
Jakub Jelinek [Wed, 4 Apr 2018 19:55:56 +0000 (21:55 +0200)]
re PR inline-asm/85172 (internal compiler error: unexpected expression '<statement>' of kind asm_expr)
PR inline-asm/85172
* constexpr.c (cxx_eval_builtin_function_call): For calls to
builtin_valid_in_constant_expr_p functions, don't call
cxx_eval_constant_expression if argument is not
potential_constant_expression.
* g++.dg/ext/builtin13.C: New test.
* g++.dg/ext/atomic-4.C: New test.
Jakub Jelinek [Wed, 4 Apr 2018 19:34:18 +0000 (21:34 +0200)]
re PR c++/85146 (ICE with __direct_bases for declared but not defined struct)
PR c++/85146
* cp-tree.h (calculate_bases, calculate_direct_bases): Add complain
argument.
* semantics.c (calculate_bases): Add complain argument. Use
complete_type_or_maybe_complain instead of just complete_type and
return an empty vector if it fails. Move make_tree_vector () call
after early return. Formatting fixes.
(calculate_direct_bases): Likewise. Call release_tree_vector at the
end.
(dfs_calculate_bases_post, calculate_bases_helper): Formatting fixes.
* pt.c (tsubst_pack_expansion): Adjust calculate_bases and
calculate_direct_bases callers, formatting fixes.
* g++.dg/ext/bases2.C: Expect extra error diagnostics.
* g++.dg/ext/bases3.C: New test.
[ARM] Fix PR85203: cmse_nonsecure_caller returns wrong result
__builtin_cmse_nonsecure_caller implementation returns true in almost
all cases due to 2 separate bugs:
* gen_addsi is used instead of gen_andsi to retrieve the lsb
* the lsb boolean value is not negated but the specification says
the intrinsic should return true for a nonsecure caller and a
nonsecure caller is characterized with LR's lsb being 0
This was not caught due to (1) lack of runtime test and (2) the existing
RTL scan not taking into account that '.' matches newline in Tcl regular
expressions.
This commit fixes the implementation issues and improves testing of
cmse_nonsecure_caller by (1) adding a runtime test for the secure caller
case and (2) looking for an SET insn of an AND expression in the right
function. This leaves the nonsecure caller case only partly tested
since the exact value being AND and the negation are not covered by the
scan and the existing test infrastructure does not allow 2 separate
compilation and link to be performed. It is enough though to catch the
current incorrect behavior.
The commit also reorganize the scan directives in cmse-1.c to more
easily identify what function they are intended to test in the file.
2018-04-04 Thomas Preud'homme <thomas.preudhomme@arm.com>
gcc/
PR target/85203
* config/arm/arm-builtins.c (arm_expand_builtin): Change
expansion to perform a bitwise AND of the argument followed by a
boolean negation of the result.
gcc/testsuite/
PR target/85203
* gcc.target/arm/cmse/cmse-1.c: Tighten cmse_nonsecure_caller RTL scan
to match a single insn of the baz function. Move scan directives at
the end of the file below the functions they are trying to test for
better readability.
* gcc.target/arm/cmse/cmse-16.c: New testcase.
Jakub Jelinek [Wed, 4 Apr 2018 17:18:14 +0000 (19:18 +0200)]
re PR other/85161 (Test case failures in libbacktrace on powerpc64 BE starting with r253456)
PR other/85161
* elf.c (elf_zlib_fetch): Fix up predefined macro names in test for
big endian, only use 32-bit loads if endianity macros are predefined
and indicate big or little endian.