178906 Commits

Author SHA1 Message Date
David Malcolm
623bc02768 analyzer: consider initializers for globals [PR96651]
PR analyzer/96651 reports a false positive in which a global
that can't have been touched yet is checked in "main".  The analyzer
fails to reject code paths in which the initial value of the global
makes the path condition impossible.

This patch detects cases where the code path begins at the entrypoint
of "main", and extracts values from initializers for globals that
can't have been touched yet, rather than using a symbolic
"INIT_VAL(REG)", fixing the false positive.

gcc/analyzer/ChangeLog:
	PR analyzer/96651
	* region-model.cc (region_model::called_from_main_p): New.
	(region_model::get_store_value): Move handling for globals into...
	(region_model::get_initial_value_for_global): ...this new
	function, and add logic for extracting values from decl
	initializers.
	* region-model.h (decl_region::get_svalue_for_constructor): New
	decl.
	(decl_region::get_svalue_for_initializer): New decl.
	(region_model::called_from_main_p): New decl.
	(region_model::get_initial_value_for_global): New.
	* region.cc (decl_region::maybe_get_constant_value): Move logic
	for getting an svalue from a CONSTRUCTOR node to...
	(decl_region::get_svalue_for_constructor): ...this new function.
	(decl_region::get_svalue_for_initializer): New.
	* store.cc (get_svalue_for_ctor_val): Rewrite in terms of
	region_model::get_rvalue.
	* store.h (binding_cluster::get_map): New accessor.

gcc/testsuite/ChangeLog:
	PR analyzer/96651
	* gcc.dg/analyzer/pr96651-1.c: New test.
	* gcc.dg/analyzer/pr96651-2.c: New test.
2020-08-18 21:21:35 -04:00
David Malcolm
400abebf48 analyzer: fix ICE with negative bit offsets [PR96648]
PR analyzer/96648 reports an ICE within get_field_at_bit_offset due
to a negative bit offset, arising due to pointer arithmetic.

This patch replaces an assertion with handling for this case, fixing the
ICE.

gcc/analyzer/ChangeLog:
	PR analyzer/96648
	* region.cc (get_field_at_bit_offset): Gracefully handle negative
	values for bit_offset.

gcc/testsuite/ChangeLog:
	PR analyzer/96648
	* gcc.dg/analyzer/pr96648.c: New test.
2020-08-18 21:20:18 -04:00
GCC Administrator
5c265693bf Daily bump. 2020-08-19 00:16:23 +00:00
Nathan Sidwell
ea2722934f c++: alias template template_info setting
During the construction of alias templates we can alter its
template_info.  This is really weird, because that's morally immutable
data.  In this case it's ok, but let's not create a duplicate
template_info, and add asserts to make sure it is changing in exactly
the way we expect.

	gcc/cp/
	* cp-tree.h (SET_TYPE_TEMPLTE_INFO): Do not deal with ALIAS templates.
	* pt.c (lookup_template_class_1): Special-case alias template
	template_info setting.
2020-08-18 14:52:22 -07:00
Peter Bergner
94bedeaf69 rs6000: Rename instruction xvcvbf16sp to xvcvbf16spn
The xvcvbf16sp mnemonic, which was just added in ISA 3.1 has been renamed
to xvcvbf16spn, to make it consistent with the other non-signaling conversion
instructions which all end with "n".  The only use of this instruction is in
an MMA conversion built-in function, so there is little to no compatibility
issue.

gcc/
	* config/rs6000/rs6000-builtin.def (BU_VSX_1): Rename xvcvbf16sp to
	xvcvbf16spn.
	* config/rs6000/rs6000-call.c (builtin_function_type): Likewise.
	* config/rs6000/vsx.md: Likewise.
	* doc/extend.texi: Likewise.

gcc/testsuite/
	* gcc.target/powerpc/mma-builtin-3.c: Rename xvcvbf16sp to xvcvbf16spn.
2020-08-18 16:18:08 -05:00
David Edelsohn
9599c9853a aix: Support libsupc++ as a FAT library
Build libstdc++++ static library libsupc++.a as a FAT 32/64 bit library.

libstdc++-v3/ChangeLog:

2020-08-18  David Edelsohn  <dje.gcc@gmail.com>
	    Clement Chigot  <clement.chigot@atos.net>

	* config/os/aix/t-aix: Add complementary mode object files to
	libsupc++.a
2020-08-18 16:55:10 -04:00
Jason Merrill
b871301f09 c++: Rewrite members for all deduction guides. [PR96199]
After the last patch, it occurred to me that we could run into the
specialization issue with non-alias deduction guides as well, so this patch
extends the rewriting to C++17 mode.

Doing this revealed that we weren't properly pushing into class scope for
normalization.

gcc/cp/ChangeLog:

	PR c++/96199
	* pt.c (tsubst_aggr_type): Rewrite in C++17, too.
	(maybe_dependent_member_ref): Likewise.
	(build_deduction_guide): Re-substitute template parms.
	* cp-tree.h (struct push_nested_class_guard): New.
	* constraint.cc (get_normalized_constraints_from_decl): Use it.

gcc/testsuite/ChangeLog:

	PR c++/96199
	* g++.dg/cpp1z/class-deduction-spec1.C: New test.
2020-08-18 16:20:09 -04:00
Jason Merrill
9125cf8c33 c++: Handle enumerator in C++20 alias CTAD. [PR96199]
To form a deduction guide for an alias template, we substitute the template
arguments from the pattern into the deduction guide for the underlying
class.  In the case of B(A1<X>), that produces B(A1<B<T,1>::X>) -> B<T,1>.
But since an enumerator doesn't have its own template info, and B<T,1> is a
dependent scope, trying to look up B<T,1>::X fails and we crash.  So we need
to produce a SCOPE_REF instead.

And trying to use the members of the template class is wrong for other
members, as well, as it gives a nonsensical result if the class is
specialized.

gcc/cp/ChangeLog:

	PR c++/96199
	* pt.c (maybe_dependent_member_ref): New.
	(tsubst_copy) [CONST_DECL]: Use it.
	[VAR_DECL]: Likewise.
	(tsubst_aggr_type): Handle nested type.

gcc/testsuite/ChangeLog:

	PR c++/96199
	* g++.dg/cpp2a/class-deduction-alias4.C: New test.
2020-08-18 16:20:08 -04:00
Harald Anlauf
3c04bd60e5 PR fortran/96613,96686 - Fix type/kind issues, temporaries evaluating MIN/MAX
When evaluating functions of the MIN/MAX variety inline, use a temporary
of appropriate type and kind, and convert to the result type at the end.
In the case of allowing for the GNU extensions to MIN/MAX, derive the
result kind consistently during simplificaton.

Furthermore, the Fortran standard requires type and kind of arguments to
the MIN/MAX intrinsics to all have the same type and kind.  While a GNU
extension accepts kind differences for integer and real arguments which
seems to have been used in legacy code, there is no reason to allow
different character kinds.  We now reject the latter unconditionally.

gcc/fortran/ChangeLog:

	* check.c (check_rest): Reject MIN/MAX character arguments of
	different kind.
	* simplify.c (min_max_choose): The simplification result shall
	have the highest kind value of the arguments.
	* trans-intrinsic.c (gfc_conv_intrinsic_minmax): Choose type and
	kind of intermediate by looking at all arguments, not the result.

gcc/testsuite/ChangeLog:

	* gfortran.dg/minmax_char_3.f90: New test.
	* gfortran.dg/min_max_kind.f90: New test.
	* gfortran.dg/pr96613.f90: New test.
2020-08-18 21:48:56 +02:00
Aaron Sawdey
afd9716398 rs6000: unaligned VSX in memcpy/memmove expansion
This patch adds a few new instructions to inline expansion of
memcpy/memmove. Generation of all these are controlled by
the option -mblock-ops-unaligned-vsx which is set on by default if the
target has TARGET_EFFICIENT_UNALIGNED_VSX.
 * unaligned vsx load/store (V2DImode)
 * unaligned vsx pair load/store (POImode) which is also controlled
   by -mblock-ops-vector-pair in case it is not wanted at some point.
   The default for -mblock-ops-vector-pair is for it to be on if the
   target has TARGET_MMA and TARGET_EFFICIENT_UNALIGNED_VSX. This is
   redundant, but nice for the future to clearly specify what is
   required.
 * unaligned vsx lxvl/stxvl but generally only to do the remainder
   of a copy/move we stated with some vsx loads/stores, and also prefer
   to use lb/lh/lw/ld if the remainder is 1/2/4/8 bytes.

Testing of this is actually accomplished by gcc.dg/memcmp-1.c which does
two memcpy() for each memcmp(). If the memcpy() calls don't do the right
thing then the memcmp() will fail unexpectedly.

gcc/ChangeLog:

	* config/rs6000/rs6000-string.c (gen_lxvl_stxvl_move):
	Helper function.
	(expand_block_move): Add lxvl/stxvl, vector pair, and
	unaligned VSX.
	* config/rs6000/rs6000.c (rs6000_option_override_internal):
	Default value for -mblock-ops-vector-pair.
	* config/rs6000/rs6000.opt: Add -mblock-ops-vector-pair.
2020-08-18 14:16:45 -05:00
Aldy Hernandez
ea95ba8d58 Decouple adjust_range_from_scev from vr_values and value_range_equiv.
gcc/ChangeLog:

	* vr-values.c (check_for_binary_op_overflow): Change type of store
	to range_query.
	(vr_values::adjust_range_with_scev): Abstract most of the code...
	(range_of_var_in_loop): ...here.  Remove value_range_equiv uses.
	(simplify_using_ranges::simplify_using_ranges): Change type of store
	to range_query.
	* vr-values.h (class range_query): New.
	(class simplify_using_ranges): Use range_query.
	(class vr_values): Add OVERRIDE to get_value_range.
	(range_of_var_in_loop): New.
2020-08-18 21:10:53 +02:00
Martin Sebor
d367f5fcb5 PR middle-end/96665 - memcmp of a constant string not folded
Related:
PR middle-end/78257 - missing memcmp optimization with constant arrays

gcc/ChangeLog:

	PR middle-end/96665
	PR middle-end/78257
	* expr.c (convert_to_bytes): Replace statically allocated buffer with
	a dynamically allocated one of sufficient size.

gcc/testsuite/ChangeLog:

	PR middle-end/96665
	PR middle-end/78257
	* gcc.dg/memcmp-5.c: New test.
2020-08-18 12:59:09 -06:00
Martin Sebor
bb04901d14 Fix PR tree-optimization/96670 - ICE on memchr with an empty initializer.
gcc/ChangeLog:

	PR tree-optimization/96670
	PR middle-end/78257
	* gimple-fold.c (gimple_fold_builtin_memchr): Call byte_representation
	to get it, not string_constant.

gcc/testsuite/ChangeLog:

	PR tree-optimization/96670
	* gcc.dg/memchr-2.c: New test.
	* gcc.dg/memcmp-6.c: New test.
2020-08-18 12:49:35 -06:00
Hu Jiangping
16bea83ae5 doc: add return type for functions in gimple.texi
gcc/
	* doc/gimple.texi (gimple_debug_begin_stmt_p): Add return type.
	(gimple_debug_inline_entry_p, gimple_debug_nonbind_marker_p): Likewise.
2020-08-18 17:47:08 +01:00
Martin Sebor
b1f58acd3a Update native_encode_expr description.
gcc/ChangeLog:
	* fold-const.c (native_encode_expr): Update comment.
2020-08-18 09:54:29 -06:00
Uros Bizjak
f8104bb9dc i386: Rewrite restore_stack_nonlocal expander [PR96536].
-fcf-protection code in restore_stack_nonlocal uses a branch based on
a clobber result.  The patch adds missing compare and completely
rewrites the expander to use high-level functions in RTL construction.

2020-08-18  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

	PR target/96536
	* config/i386/i386.md (restore_stack_nonlocal): Add missing compare
	RTX.  Rewrite expander to use high-level functions in RTL construction.
2020-08-18 17:31:49 +02:00
Jonathan Wakely
6c1a58b7fb libstdc++: Add "cold" to tests for reserved attribute names
libstdc++-v3/ChangeLog:

	* testsuite/17_intro/headers/c++1998/all_attributes.cc: Check
	"cold" isn't used in the library. Also check <cxxabi.h>.
	* testsuite/17_intro/headers/c++2011/all_attributes.cc:
	Likewise.
	* testsuite/17_intro/headers/c++2014/all_attributes.cc:
	Likewise.
	* testsuite/17_intro/headers/c++2017/all_attributes.cc:
	Likewise.
	* testsuite/17_intro/headers/c++2020/all_attributes.cc:
	Likewise.
2020-08-18 15:37:33 +01:00
Roger Sayle
d850dec9b7 New tests for PR rtl-optimization/96298.
Tests to confirm PR rtl-optimization is now fixed, remains so.

2020-08-18  Roger Sayle  <roger@nextmovesoftware.com>
	    Zdenek Sojka  <zsojka@seznam.cz>

gcc/testsuite/ChangeLog
	PR rtl-optimization/96298
	* gcc.dg/pr96298.c: New test.
	* gcc.target/i386/pr96298.c: New test.
2020-08-18 14:45:52 +01:00
Jonathan Wakely
bb1b7f087b libstdc++: Remove redundant copying of std::async arguments [PR 69724]
As was previously done for std::thread, this removes an unnecessary copy
of an rvalue of type thread::_Invoker. Instead of creating the rvalue
and then moving that into the shared state, the member of the shared
state is initialized directly from the forwarded callable and bound
arguments.

This also slightly simplifies std::thread creation to remove the
_S_make_state helper function.

libstdc++-v3/ChangeLog:

	PR libstdc++/69724
	* include/std/future (__future_base::_S_make_deferred_state)
	(__future_base::_S_make_async_state): Remove.
	(__future_base::_Deferred_state): Change constructor to accept a
	parameter pack of arguments and forward them to the call
	wrapper.
	(__future_base::_Async_state_impl): Likewise. Replace lambda
	expression with a named member function.
	(async): Construct state object directly from the arguments,
	instead of using thread::__make_invoker, _S_make_deferred_state
	and _S_make_async_state. Move shared state into the returned
	future.
	* include/std/thread (thread::_Call_wrapper): New alias
	template for use by constructor and std::async.
	(thread::thread(Callable&&, Args&&...)): Create state object
	directly instead of using _S_make_state.
	(thread::__make_invoker, thread::__decayed_tuple)
	(thread::_S_make_state): Remove.
	* testsuite/30_threads/async/69724.cc: New test.
2020-08-18 14:28:38 +01:00
Nathan Sidwell
634046d1a8 c++: Move hidden-lambda entity lookup checking
Hidden lambda entities only occur in block and class scopes.  There's
no need to check for them on every lookup.  So moving that particular
piece of validation to lookup_name_1, which cares.  Also reordered the
namespace and type checking, as that is also simpler.

	gcc/cp/
	* name-lookup.c (qualify_lookup): Drop lambda checking here.
	Reorder namespace & type checking.
	(lookup_name_1): Do hidden lambda checking here.
2020-08-18 06:05:04 -07:00
Iain Buclaw
6bebbc033d d: Fix ICE Segmentation fault during RTL pass: expand on armhf/armel/s390x
gcc/d/ChangeLog:

	PR d/96301
	* decl.cc (DeclVisitor::visit (FuncDeclaration *)): Only return
	non-trivial structs by invisible reference.

gcc/testsuite/ChangeLog:

	PR d/96301
	* gdc.dg/pr96301a.d: New test.
	* gdc.dg/pr96301b.d: New test.
	* gdc.dg/pr96301c.d: New test.
2020-08-18 09:55:09 +02:00
liuhongt
7d5de349d2 Don't use pinsr/pextr for struct initialization/extraction.
gcc/
	PR target/96562
	PR target/93897
	* config/i386/i386-expand.c (ix86_expand_pinsr): Don't use
	pinsr for TImode.
	(ix86_expand_pextr): Don't use pextr for TImode.

gcc/testsuite/
	* gcc.target/i386/pr96562-1.c: New test.
2020-08-18 14:19:40 +08:00
Jakub Jelinek
6d42cbe5ad c: Fix -Wunused-but-set-* warning with _Generic [PR96571]
The following testcase shows various problems with -Wunused-but-set*
warnings and _Generic construct.  I think it is best to treat the selector
and the ignored expressions as (potentially) read, because when they are
parsed, the vars in there are already marked as TREE_USED.

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

	PR c/96571
	* c-parser.c (c_parser_generic_selection): Change match_found from bool
	to int, holding index of the match.  Call mark_exp_read on the selector
	expression and on expressions other than the selected one.

	* gcc.dg/Wunused-var-4.c: New test.
2020-08-18 07:51:58 +02:00
liuhongt
1bc4e811aa Adjust testcase.
Since This testcase is used to check generation of AVX512 vector
comparison, scan-assembler for vmov instruction could be deleted, also
-mprefer-vector-width=512 is added to avoid impact of different
default arch/tune of GCC.

gcc/testsuite
	PR target/96574
	* gcc.target/i386/pr92865-1.c: Adjust testcase.
2020-08-18 13:45:02 +08:00
David Malcolm
da7c2773e5 analyzer: fix name of local in region_model::get_rvalue_1
gcc/analyzer/ChangeLog:
	* region-model.cc (region_model::get_rvalue_1): Fix name of local.
2020-08-17 20:48:01 -04:00
David Malcolm
2242b975c0 analyzer: fix ICE on unhandled tree codes in get_rvalue_1 [PR96641]
The old implementation of region_model::get_rvalue_1 gracefully handled
tree codes it didn't understand, returning "UNKNOWN", whereas the new
implementation (r11-2694-g808f4dfeb3a95f50f15e71148e5c1067f90a126d) had
an assertion left over from development, leading to ICEs.

This patch restores the old behavior for these cases.

gcc/analyzer/ChangeLog:
	PR analyzer/96641
	* region-model.cc (region_model::get_rvalue_1): Handle
	unrecognized tree codes by returning "UNKNOWN.

gcc/testsuite/ChangeLog:
	PR analyzer/96641
	* g++.dg/analyzer/pr96641.C: New test.
2020-08-17 20:46:49 -04:00
David Malcolm
1b0be82220 analyzer: fix ICE on unhandled tree codes in gassign [PR96640]
PR analyzer/96640 reports a ICE within region_model::on_assignment when
failing to handle a WIDEN_MULT_EVEN_EXPR, and various other tree codes.

The old implementation of region_model::on_assignment gracefully handled
tree codes it didn't understand, returning "UNKNOWN", whereas the new
implementation (r11-2694-g808f4dfeb3a95f50f15e71148e5c1067f90a126d) had
a "sorry_at" and an assertion left over from development, leading to ICEs.

This patch restores the old behavior for these cases, and marks various
vector operations as leading to unknown results.

gcc/analyzer/ChangeLog:
	PR analyzer/96640
	* region-model.cc (region_model::get_gassign_result): Handle various
	VEC_* tree codes by returning UNKNOWN.
	(region_model::on_assignment): Handle unrecognized tree codes by
	setting lhs to an unknown value, rather than issuing a "sorry" and
	asserting.
2020-08-17 20:45:53 -04:00
GCC Administrator
deee2322a2 Daily bump. 2020-08-18 00:16:26 +00:00
Ian Lance Taylor
f99dc8f89d compiler: export thunks referenced by inline functions
The test case is https://golang.org/cl/248637.

Fixes golang/go#40252

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/248638
2020-08-17 16:32:53 -07:00
David Malcolm
b00a830475 analyzer: fix ICE on NULL dereference [PR96644]
gcc/analyzer/ChangeLog:
	PR analyzer/96644
	* region-model-manager.cc (get_region_for_unexpected_tree_code):
	Handle ctxt being NULL.

gcc/testsuite/ChangeLog:
	PR analyzer/96644
	* gcc.dg/analyzer/pr96644.c: New test.
2020-08-17 14:47:18 -04:00
David Malcolm
42c5ae5d7f analyzer: fix ICE due to NULL type [PR96639]
gcc/analyzer/ChangeLog:
	PR analyzer/96639
	* region.cc (region::get_subregions_for_binding): Check for "type"
	being NULL.

gcc/testsuite/ChangeLog:
	PR analyzer/96639
	* gcc.dg/analyzer/pr96639.c: New test.
2020-08-17 14:46:10 -04:00
David Malcolm
35c5f8fb43 analyzer: handle &STRING_CST in constant pool initializers [PR96642]
In r11-2708-g2867118ddda9b56d991c16022f7d3d634ed08313 I added support to
the analyzer for initialization from var_decls in the global constant
pool.  However, that commit didn't support initialization from
ADDR_EXPR of a STRING_CST leading to an ICE seen in data-model-1.c and
pr94639.c on arm and powerpc64 at least, and as PR analyzer/96642 on
x86_64 at least.

This patch adds support for such initializers, fixing the ICE.

gcc/analyzer/ChangeLog:
	PR analyzer/96642
	* store.cc (get_svalue_for_ctor_val): New.
	(binding_map::apply_ctor_to_region): Call it.

gcc/testsuite/ChangeLog:
	PR analyzer/96642
	* gcc.dg/analyzer/pr96642.c: New test.
2020-08-17 14:45:00 -04:00
Uros Bizjak
9e02619154 i386: Use parametrized pattern names some more.
Use parameterized pattern names to simplify calling of named patterns.

2020-08-15  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

	* config/i386/i386-builtin.def (__builtin_ia32_bextri_u32)
	(__builtin_ia32_bextri_u64): Use CODE_FOR_nothing.
	* config/i386/i386.md (@tbm_bextri_<mode>):
	Implement as parametrized name pattern.
	(@rdrand<mode>): Ditto.
	(@rdseed<mode>): Ditto.
	* config/i386/i386-expand.c (ix86_expand_builtin)
	[case IX86_BUILTIN_BEXTRI32, case IX86_BUILTIN_BEXTRI64]:
	Update for parameterized name patterns.
	[case IX86_BUILTIN_RDRAND16_STEP, case IX86_BUILTIN_RDRAND32_STEP]
	[case IX86_BUILTIN_RDRAND64_STEP]: Ditto.
	[case IX86_BUILTIN_RDSEED16_STEP, case IX86_BUILTIN_RDSEED32_STEP]
	[case IX86_BUILTIN_RDSEED64_STEP]: Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/rdrand-1.c (dg-final): Update scan string.
	* gcc.target/i386/rdrand-2.c (dg-final): Ditto.
	* gcc.target/i386/rdrand-3.c (dg-final): Ditto.
2020-08-17 20:41:14 +02:00
David Edelsohn
26fdc47da7 aix: Support libgfortran libcaf_single.a as a FAT library
Build libgfortran static library libcaf_single.a as a FAT 32/64 bit library.

libgfortran/ChangeLog:

2020-08-17  David Edelsohn  <dje.gcc@gmail.com>
	    Clement Chigot  <clement.chigot@atos.net>

	* config/t-aix: Add complementary mode object file to libcaf_single.a.
2020-08-17 14:05:41 -04:00
Jonathan Wakely
91e6226f88 libstdc++: Remove inheritance from elements in std::tuple
This fixes a number of std::tuple bugs by no longer making use of the
empty base-class optimization. By using the C++20 [[no_unique_address]]
attribute we can always store the element as a data member, while still
compressing the layout of tuples containing empty types.

Since we no longer use inheritance we could also apply the compression
optimization for final types and for tuples of tuples, but doing so
would be an ABI break.

Using [[no_unique_address]] more liberally for the unstable std::__8
configuration is left for a later date. There may be reasons not to
apply the attribute unconditionally, e.g. see the discussion about
guaranteed elision in PR 94062.

libstdc++-v3/ChangeLog:

	PR libstdc++/55713
	PR libstdc++/71096
	PR libstdc++/93147
	* include/std/tuple [__has_cpp_attribute(no_unique_address)]
	(_Head_base<Idx, Head, true>): New definition of the partial
	specialization, using [[no_unique_address]] instead of
	inheritance.
	* testsuite/libstdc++-prettyprinters/48362.cc: Adjust expected
	output.
	* testsuite/20_util/tuple/comparison_operators/93147.cc: New test.
	* testsuite/20_util/tuple/creation_functions/55713.cc: New test.
	* testsuite/20_util/tuple/element_access/71096.cc: New test.
2020-08-17 15:27:51 +01:00
Martin Liska
929c4051af opnemp: add static assert for clause_names.
gcc/fortran/ChangeLog:

	* openmp.c (resolve_omp_clauses): Add static assert
	for OMP_LIST_NUM and size of clause_names array.
	Remove check that is always true.
2020-08-17 13:57:55 +02:00
Aldy Hernandez
d8b8023cdb Add statement context to get_value_range.
This is in line with the statement context that we have for get_value()
in the substitute_and_fold_engine class.

gcc/ChangeLog:

	* vr-values.c (vr_values::get_value_range): Add stmt param.
	(vr_values::extract_range_from_comparison): Same.
	(vr_values::extract_range_from_assignment): Pass stmt to
	extract_range_from_comparison.
	(vr_values::adjust_range_with_scev): Pass stmt to get_value_range.
	(simplify_using_ranges::vrp_evaluate_conditional): Add stmt param.
	Pass stmt to get_value_range.
	(simplify_using_ranges::vrp_visit_cond_stmt): Pass stmt to
	get_value_range.
	(simplify_using_ranges::simplify_abs_using_ranges): Same.
	(simplify_using_ranges::simplify_div_or_mod_using_ranges): Same.
	(simplify_using_ranges::simplify_bit_ops_using_ranges): Same.
	(simplify_using_ranges::simplify_cond_using_ranges_1): Same.
	(simplify_using_ranges::simplify_switch_using_ranges): Same.
	(simplify_using_ranges::simplify_float_conversion_using_ranges): Same.
	* vr-values.h (class vr_values): Add stmt arg to
	vrp_evaluate_conditional_warnv_with_ops.
	Add stmt arg to extract_range_from_comparison and get_value_range.
	(simplify_using_ranges::get_value_range): Add stmt arg.
2020-08-17 11:07:30 +02:00
Martin Liska
5625b2c56a openmp: fix UBSAN error at gcc/fortran/openmp.c:4737
Since 21cfe724cbdc30612bf1ef59b26f19ada2210832 there's a new
OMP_LIST_NONTEMPORAL value, but it was missing in
resolve_omp_clauses static array that is defined at the function
beginning:

./xgcc -B. /home/marxin/Programming/gcc/gcc/testsuite/gfortran.dg/gomp/nontemporal-1.f90 -fopenmp -c
../../gcc/fortran/openmp.c:4737:28: runtime error: index 21 out of bounds for type 'char *[21]'
    #0 0xbdb956 in resolve_omp_clauses ../../gcc/fortran/openmp.c:4737
    #1 0xbeb076 in resolve_omp_do ../../gcc/fortran/openmp.c:6139
    #2 0xbf029a in gfc_resolve_omp_directive(gfc_code*, gfc_namespace*) ../../gcc/fortran/openmp.c:6792
    #3 0xcb6363 in gfc_resolve_code(gfc_code*, gfc_namespace*) ../../gcc/fortran/resolve.c:12185
    #4 0xcef8cf in resolve_codes ../../gcc/fortran/resolve.c:17303

gcc/fortran/ChangeLog:

	* openmp.c (resolve_omp_clauses): Add NONTEMPORAL to clause
	names.
2020-08-17 11:02:36 +02:00
liuhongt
9a5381f749 Force ENDBR immediate into memory.
gcc/
	PR target/96350
	* config/i386/i386.c (ix86_legitimate_constant_p): Return
	false for ENDBR immediate.
	(ix86_legitimate_address_p): Ditto.
	* config/i386/predicates.md
	(x86_64_immediate_operand): Exclude ENDBR immediate.
	(x86_64_zext_immediate_operand): Ditto.
	(x86_64_dwzext_immediate_operand): Ditto.
	(ix86_endbr_immediate_operand): New predicate.

gcc/testsuite
	* gcc.target/i386/endbr_immediate.c: New test.
2020-08-17 10:40:06 +08:00
GCC Administrator
2c4c56c249 Daily bump. 2020-08-17 00:16:19 +00:00
Roger Sayle
c99116aeeb middle-end: Simplify (sign_extend:HI (truncate:QI (ashiftrt:HI X 8)))
The combination of several my recent nvptx patches has revealed an
interesting RTL optimization opportunity.  This patch to simplify-rtx.c
simplifies (sign_extend:HI (truncate:QI (?shiftrt:HI x 8))) to just
(ashiftrt:HI x 8), as the inner shift already sets the high bits
appropriately.  The equivalent zero_extend variant appears to already
be implemented in simplify_unary_operation_1.

These result from RTL expansion generating a reasonable arithmetic right
shift and truncation to char, only to then discover the backend doesn't
support QImode comparisons, so the next optab widens this result/operand
back to HImode.  In this sequence the truncate and sign extend are
redundant as the original arithmetic shift has already set the high
bits appropriately.  The one oddity of the patch is that it tests for
LSHIFTRT as inner shift, as simplify/combine has already canonicalized
this to a logical shift, assuming that the distinction is unimportant
following the truncatation.

2020-08-16  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
	* simplify-rtx.c (simplify_unary_operation_1) [SIGN_EXTEND]:
	Simplify (sign_extend:M (truncate:N (lshiftrt:M x C))) to
	(ashiftrt:M x C) when the shift sets the high bits appropriately.
2020-08-16 19:20:27 +01:00
Sergei Trofimovich
10218124c6 MAINTAINERS: Add myself for write after approval
2020-08-16  Sergei Trofimovich  <slyfox@gcc.gnu.org>

	* MAINTAINERS (Write After Approval): Add myself.
2020-08-16 09:28:10 +01:00
GCC Administrator
23747614cc Daily bump. 2020-08-16 00:16:21 +00:00
GCC Administrator
661ee09b8b Daily bump. 2020-08-15 00:16:22 +00:00
Nathan Sidwell
f00008b45a c++: Final bit of name-lookup api simplification
We no longer need to give name_lookup_real not name_lookup_nonclass
different names to the name_lookup functions.  This renames the lookup
functions thusly.

	gcc/cp/
	* name-lookup.h (lookup_name_real, lookup_name_nonclass): Rename
	to ...
	(lookup_name): ... these new overloads.
	* name-lookup.c (identifier_type_value_1): Rename lookup_name_real
	call.
	(lookup_name_real_1): Rename to ...
	(lookup_name_1): ... here.
	(lookup_name_real): Rename to ...
	(lookup_name): ... here.  Rename lookup_name_real_1 call.
	(lookup_name_nonclass): Delete.
	* call.c (build_operator_new_call): Rename lookup_name_real call.
	(add_operator_candidates): Likewise.
	(build_op_delete_call): Rename lookup_name_nonclass call.
	* parser.c (cp_parser_lookup_name): Likewise.
	* pt.c (tsubst_friend_class, lookup_init_capture_pack): Likewise.
	(tsubst_expr): Likewise.
	* semantics.c (capture_decltype): Likewise.
	libcc1/
	* libcp1plugin.cc (plugin_build_dependent_expr): Rename
	lookup_name_real call.
2020-08-14 16:55:35 -07:00
Martin Sebor
866626efd7 PR tree-optimization/78257 - missing memcmp optimization with constant arrays
gcc/ChangeLog:

	PR middle-end/78257
	* builtins.c (expand_builtin_memory_copy_args): Rename called function.
	(expand_builtin_stpcpy_1): Remove argument from call.
	(expand_builtin_memcmp): Rename called function.
	(inline_expand_builtin_bytecmp): Same.
	* expr.c (convert_to_bytes): New function.
	(constant_byte_string): New function (formerly string_constant).
	(string_constant): Call constant_byte_string.
	(byte_representation): New function.
	* expr.h (byte_representation): Declare.
	* fold-const-call.c (fold_const_call): Rename called function.
	* fold-const.c (c_getstr): Remove an argument.
	(getbyterep): Define a new function.
	* fold-const.h (c_getstr): Remove an argument.
	(getbyterep): Declare a new function.
	* gimple-fold.c (gimple_fold_builtin_memory_op): Rename callee.
	(gimple_fold_builtin_string_compare): Same.
	(gimple_fold_builtin_memchr): Same.

gcc/testsuite/ChangeLog:

	PR middle-end/78257
	* gcc.dg/memchr.c: New test.
	* gcc.dg/memcmp-2.c: New test.
	* gcc.dg/memcmp-3.c: New test.
	* gcc.dg/memcmp-4.c: New test.
2020-08-14 17:11:53 -06:00
David Malcolm
2867118ddd analyzer: fix initialization from constant pool [PR96609,PR96616]
PR testsuite/96609 and PR analyzer/96616 report various testsuite
failures seen on powerpc64, aarch64, and arm in new tests added by
r11-2694-g808f4dfeb3a95f50f15e71148e5c1067f90a126d.

Some of these failures (in gcc.dg/analyzer/init.c, and on arm
in gcc.dg/analyzer/casts-1.c) relate to initializations from var_decls
in the constant pool.  I wrote the tests assuming that the gimplified
stmts would initialize the locals via a gassign of code CONSTRUCTOR,
whereas on these targets some of the initializations are gassign from
a VAR_DECL e.g.:
  c = *.LC0;
where "*.LC0" is a var_decl with DECL_IN_CONSTANT_POOL set.

For example, in test_7:
   struct coord c[2] = {{3, 4}, {5, 6}};
   __analyzer_eval (c[0].x == 3); /* { dg-warning "TRUE" } */
after the initialization, the store was simply recording:
   cluster for: c: INIT_VAL(*.LC0)
when I was expecting the cluster for c to have:
  cluster for: c
    key:   {kind: direct, start: 0, size: 32, next: 32}
    value: 'int' {(int)3}
    key:   {kind: direct, start: 32, size: 32, next: 64}
    value: 'int' {(int)4}
    key:   {kind: direct, start: 64, size: 32, next: 96}
    value: 'int' {(int)5}
    key:   {kind: direct, start: 96, size: 32, next: 128}
    value: 'int' {(int)6}
The test for c[0].x == 3 would then generate:
  cluster for: _2: (SUB(SUB(INIT_VAL(*.LC0), c[(int)0]), c[(int)0].x)==(int)3)
which is UNKNOWN, leading to the test failing.

This patch fixes the init.c and casts-1.c failures by special-casing
reads from a var_decl with DECL_IN_CONSTANT_POOL set, so that they build
a compound_svalue containing the bindings implied by the CONSTRUCTOR
node for DECL_INITIAL.

gcc/analyzer/ChangeLog:
	PR testsuite/96609
	PR analyzer/96616
	* region-model.cc (region_model::get_store_value): Call
	maybe_get_constant_value on decl_regions first.
	* region-model.h (decl_region::maybe_get_constant_value): New decl.
	* region.cc (decl_region::get_stack_depth): Likewise.
	(decl_region::maybe_get_constant_value): New.
	* store.cc (get_subregion_within_ctor): New.
	(binding_map::apply_ctor_to_region): New.
	* store.h (binding_map::apply_ctor_to_region): New decl.
2020-08-14 18:43:16 -04:00
David Malcolm
ee88b53606 analyzer: fix ICE on escaped unknown pointers [PR96611]
PR analyzer/96611 reports an ICE within the handling for unknown
functions, when passing a pointer to something accessed via a
global pointer, after an unknown function has already been called.

The first unknown function leads to the store being flagged, so
the access to the global pointer leads to (*unknown_svalue) for
the base region of the argument to the 2nd function, and thus
*unknown_svalue being reachable by the 2nd unknown function,
triggering an assertion failure.

Handle this case by rejecting attempts to get a cluster for
the unknown pointer, fixing the ICE.

gcc/analyzer/ChangeLog:
	PR analyzer/96611
	* store.cc (store::mark_as_escaped): Reject attempts to
	get a cluster for an unknown pointer.

gcc/testsuite/ChangeLog:
	PR analyzer/96611
	* gcc.dg/analyzer/pr96611.c: New test.
2020-08-14 16:56:28 -04:00
David Malcolm
7e62503862 analyzer: document how to get gimple dump from an ICE
gcc/ChangeLog:
	* doc/analyzer.texi (Overview): Add tip about how to get a
	gimple dump if the analyzer ICEs.
2020-08-14 16:55:39 -04:00
Nathan Sidwell
db1c2a89db c++: Yet more name-lookup api simplification
This patch deals with LOOKUP_HIDDEN, which originally meant 'find
hidden friends', but it's being pressed into service for not ignoring
lambda-relevant internals.  However these two functions are different.
(a) hidden friends can occur in block scope (very uncommon) and (b) it
had the semantics of stopping after the innermost enclosing
namepspace.  That's really suspect for the lambda case, but not
relevant there because we never get to namespace scope (I think).
Anyway, I've split the flag into two and adjusted the lambda callers
to just search block scope.  These two flags are added to the
LOOK_want enum class, which allows dropping another parameter from the
name lookup routines.

The remaining LOOKUP_$FOO flags in cp-tree.h are, I think, now all
related to features of overload resolution, conversion operators and
reference binding.  Nothing to do with /name/ lookup.

	gcc/cp/
	* cp-tree.h (LOOKUP_HIDDEN): Delete.
	(LOOKUP_PREFER_RVALUE): Adjust initializer.
	* name-lookup.h (enum class LOOK_want): Add HIDDEN_FRIEND and
	HIDDEN_LAMBDA flags.
	(lookup_name_real): Drop flags parm.
	(lookup_qualified_name): Drop find_hidden parm.
	* name-lookup.c (class name_lookup): Drop hidden field, adjust
	ctors.
	(name_lookup::add_overload): Check want for hiddenness.
	(name_lookup::process_binding): Likewise.
	(name_lookup::search_unqualified): Likewise.
	(identifier_type_value_1): Adjust lookup_name_real call.
	(set_decl_namespace): Adjust name_lookup ctor.
	(qualify_lookup): Drop flags parm, use want for hiddenness.
	(lookup_qualified_name): Drop find_hidden parm.
	(lookup_name_real_1): Drop flags parm, adjust qualify_lookup
	calls.
	(lookup_name_real): Drop flags parm.
	(lookup_name_nonclass, lookup_name): Adjust lookup_name_real
	calls.
	(lookup_type_scope_1): Adjust qualify_lookup calls.
	* call.c (build_operator_new_call): Adjust lookup_name_real call.
	(add_operator_candidates): Likewise.
	* coroutines.cc (morph_fn_to_coro): Adjust lookup_qualified_name
	call.
	* parser.c (cp_parser_lookup_name): Adjust lookup_name_real calls.
	* pt.c (check_explicit_specialization): Adjust
	lookup_qualified_name call.
	(deduction_guides_for): Likewise.
	(tsubst_friend_class): Adjust lookup_name_real call.
	(lookup_init_capture_pack): Likewise.
	(tsubst_expr): Likewise, don't look in namespaces.
	* semantics.c (capture_decltype): Adjust lookup_name_real.  Don't
	look in namespaces.
	libcc1/
	* libcp1plugin.cc (plugin_build_dependent_exp): Adjust
	lookup_name_real call.
2020-08-14 10:54:53 -07:00