gcc.git
4 years agoIPA tracking of EAF flags in ipa-modref.
Jan Hubicka [Mon, 16 Nov 2020 18:30:45 +0000 (19:30 +0100)]
IPA tracking of EAF flags in ipa-modref.

this patch implements the IPA propagation part of EAF flags handling in
ipa-modref.  It extends the local analysis to collect lattice consisting of
flags and escape points.  SSA name escapes if it is passed directly or
indirectly to a function call.

If useful flags are found for parameter its escape list is stored into escape
summaries.  This time each call site is annotated with info on which function
parameters escape to what argument of function call.

At IPA time we then perform iterative dataflow and produce final flags.
ipa-modref is still cheaper than pure-const when running on cc1plus (about 2-3%
that is what accounts every non-trivial passs) and the dataflow converges in 1
or 2 iterations.

Local analysis does some work to avoid streaming escape points when they are
not useful to determine final flags (that is, local escape analysis determined
good enough flags). For cc1plus there are 225k calls with useful escape
summary.

* ipa-modref.c (escape_point): New type.
(modref_lattice): New type.
(escape_entry): New type.
(escape_summary): New type.
(escape_summaries_t): New type.
(escape_summaries): New static variable.
(eaf_flags_useful_p): New function.
(modref_summary::useful_p): Add new check_flags
attribute; check eaf_flags for usefulness.
(modref_summary_lto): Add arg_flags.
(modref_summary_lto::useful_p): Add new check_flags
attribute; check eaf_flags for usefulness.
(dump_modref_edge_summaries): New function.
(remove_modref_edge_summaries): New function.
(ignore_retval_p): New predicate.
(ignore_stores_p): Also ignore for const.
(remove_summary): Call remove_modref_edge_summaries.
(modref_lattice::init): New member function.
(modref_lattice::release): New member unction.
(modref_lattice::dump): New member function.
(modref_lattice::add_escape_point): New member function.
(modref_lattice::merge): Two new member functions.
(modref_lattice::merge_deref): New member functions.
(modref_lattice::merge_direct_load): New member function.
(modref_lattice::merge_direct_store): New member function.
(call_lhs_flags): Rename to ...
(merge_call_lhs_flags): ... this one; reimplement using
modreflattice.
(analyze_ssa_name_flags): Replace KNOWN_FLAGS param by LATTICE;
add IPA parametr; use modref_lattice.
(analyze_parms): New parameter IPA and SUMMARY_LTO; update for
modref_lattice; initialize escape_summary.
(analyze_function): Allocate escape_summaries; update uses of useful_p.
(modref_write_escape_summary): New function.
(modref_read_escape_summary): New function.
(modref_write): Write escape summary.
(read_section): Read escape summary.
(modref_read): Initialie escape_summaries.
(remap_arg_flags): New function.
(update_signature): Use it.
(escape_map): New structure.
(update_escape_summary_1, update_escape_summary): New functions.
(ipa_merge_modref_summary_after_inlining): Merge escape summaries.
(propagate_unknown_call): Do not remove useless summaries.
(remove_useless_summaries): Remove them here.
(modref_propagate_in_scc): Update; do not dump scc.
(modref_propagate_dump_scc): New function.
(modref_merge_call_site_flags): New function.
(modref_propagate_flags_in_scc): New function.
(pass_ipa_modref::execute): Use modref_propagate_flags_in_scc
and modref_propagate_dump_scc; delete escape_summaries.
(ipa_modref_c_finalize):  Remove escape_summaries.
* ipa-modref.h (modref_summary): Update prototype of useful_p.
* params.opt (param=modref-max-escape-points): New param.
* doc/invoke.texi (modref-max-escape-points): Document.

4 years agoDisable some bogus -Wmaybe-uninitialized warnings
Jan Hubicka [Mon, 16 Nov 2020 15:31:30 +0000 (16:31 +0100)]
Disable some bogus -Wmaybe-uninitialized warnings

gcc/ChangeLog:
PR middle-end/97840
* ipa-modref.c (analyze_ssa_name_flags): Skip clobbers if inlining
is done.
* tree-ssa-uninit.c (maybe_warn_pass_by_reference): Make stmt gcall;
skip const calls and unused arguments.
(warn_uninitialized_vars): Update prototype.

gcc/testsuite/ChangeLog:
* g++.dg/warn/uninit-1.C: New test.

4 years agoDelay SLP instance loads gathering
Richard Biener [Mon, 16 Nov 2020 13:26:20 +0000 (14:26 +0100)]
Delay SLP instance loads gathering

This delays filling SLP_INSTANCE_LOADS.

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

* tree-vectorizer.h (vect_gather_slp_loads): Declare.
* tree-vect-loop.c (vect_analyze_loop_2): Call
vect_gather_slp_loads.
* tree-vect-slp.c (vect_build_slp_instance): Do not gather
SLP loads here.
(vect_gather_slp_loads): Remove wrapper, new function.
(vect_slp_analyze_bb_1): Call it.

4 years agofurther optimize non-store-motion LIM
Richard Biener [Mon, 16 Nov 2020 13:25:56 +0000 (14:25 +0100)]
further optimize non-store-motion LIM

This removes useless work from LIM when store-motion is disabled.

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

* tree-ssa-loop-im.c (analyze_memory_references): Add
store_motion parameter and elide unnecessary work.
(tree_ssa_lim_initialize): Likewise.
(loop_invariant_motion_in_fun): Pass down store_motion.

4 years agoIBM Z: Do not run long double tests on old machines
Ilya Leoshkevich [Thu, 12 Nov 2020 14:32:04 +0000 (15:32 +0100)]
IBM Z: Do not run long double tests on old machines

gcc/testsuite/ChangeLog:

2020-11-12  Ilya Leoshkevich  <iii@linux.ibm.com>

* gcc.target/s390/s390.exp (check_effective_target_s390_z14_hw):
New predicate.
* gcc.target/s390/vector/long-double-caller-abi-run.c: Use the
new predicate.
* gcc.target/s390/vector/long-double-copysign.c: Likewise.
* gcc.target/s390/vector/long-double-from-double.c: Likewise.
* gcc.target/s390/vector/long-double-from-float.c: Likewise.
* gcc.target/s390/vector/long-double-from-i16.c: Likewise.
* gcc.target/s390/vector/long-double-from-i32.c: Likewise.
* gcc.target/s390/vector/long-double-from-i64.c: Likewise.
* gcc.target/s390/vector/long-double-from-i8.c: Likewise.
* gcc.target/s390/vector/long-double-from-u16.c: Likewise.
* gcc.target/s390/vector/long-double-from-u32.c: Likewise.
* gcc.target/s390/vector/long-double-from-u64.c: Likewise.
* gcc.target/s390/vector/long-double-from-u8.c: Likewise.
* gcc.target/s390/vector/long-double-to-double.c: Likewise.
* gcc.target/s390/vector/long-double-to-float.c: Likewise.
* gcc.target/s390/vector/long-double-to-i16.c: Likewise.
* gcc.target/s390/vector/long-double-to-i32.c: Likewise.
* gcc.target/s390/vector/long-double-to-i64.c: Likewise.
* gcc.target/s390/vector/long-double-to-i8.c: Likewise.
* gcc.target/s390/vector/long-double-to-u16.c: Likewise.
* gcc.target/s390/vector/long-double-to-u32.c: Likewise.
* gcc.target/s390/vector/long-double-to-u64.c: Likewise.
* gcc.target/s390/vector/long-double-to-u8.c: Likewise.
* gcc.target/s390/vector/long-double-wfaxb.c: Likewise.
* gcc.target/s390/vector/long-double-wfdxb.c: Likewise.
* gcc.target/s390/vector/long-double-wfsxb-1.c: Likewise.

4 years agomodref: add missing Param Optimization keywords
Martin Liska [Mon, 16 Nov 2020 12:13:40 +0000 (13:13 +0100)]
modref: add missing Param Optimization keywords

Fixes:

FAIL: compiler driver --help=common option(s): "^ +-.*[^:.]$" absent from output: "  --param=modref-max-depth=   Maximum depth of DFS walk used by modref escape analysis"

gcc/ChangeLog:

* params.opt: All modref parameters miss Optimization and Param
keyword as seen in testsuite failure.

4 years agoFix -param=modref-max-depth in params.opt
Jan Hubicka [Mon, 16 Nov 2020 12:23:16 +0000 (13:23 +0100)]
Fix -param=modref-max-depth in params.opt

* params.opt (-param=modref-max-depth=): Add missing full stop.

4 years agopointer-compare-1.c: Add __attribute__((used))
H.J. Lu [Wed, 11 Nov 2020 23:54:00 +0000 (15:54 -0800)]
pointer-compare-1.c: Add __attribute__((used))

c-c++-common/asan/pointer-compare-1.c assumes the certain order for
variable placement.  Add __attribute__((used)) to avoid variable
placement changes due to SHF_GNU_RETAIN.

PR testsuite/97803
* c-c++-common/asan/pointer-compare-1.c (global1): Add
__attribute__((used))
(global2): Likewise.
(small_global): Likewise.
(large_global): Likewise.

4 years agolibstdc++: Fix error shown during Solaris build
Jonathan Wakely [Fri, 13 Nov 2020 19:11:02 +0000 (19:11 +0000)]
libstdc++: Fix error shown during Solaris build

Currently this is shown when building libstdc++ on Solaris:

-lrt: open: No such file or directory

The error comes from the make_sunver.pl script which tries to open each
of its arguments. The arguments are passed by this make rule:

perl ${glibcxx_srcdir}/scripts/make_exports.pl \
  libstdc++-symbols.ver \
  $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
 `echo $(libstdc___la_LIBADD) | \
    sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
 > $@ || (rm -f $@ ; exit 1)

The $(libstdc___la_LIBADD) variable includes $(GLIBCXX_LIBS) which
contains -lrt on Solaris.

This patch adds another sed script to filter -l arguments from the echo
command. In order to reliably match ' -l[^ ]* ' the echo arguments are
quoted and a space added before and after them. This might be overkill
just to remove -lrt from the start of the string, but should be robust
in case other -l arguments are added to $(GLIBCXX_LIBS), or in case the
$(libstdc___la_LIBADD) libraries are reordered.

libstdc++-v3/ChangeLog:

* src/Makefile.am (libstdc++-symbols.ver-sun): Remove -lrt from
arguments passed to make_sunver.pl script.
* src/Makefile.in: Regenerate.

4 years agoAdd .cache to git ignore.
Martin Liska [Mon, 16 Nov 2020 11:52:43 +0000 (12:52 +0100)]
Add .cache to git ignore.

ChangeLog:

* .gitignore: Add cache as clangd uses it now.

4 years agogcov: Add -fprofile-info-section support
Sebastian Huber [Fri, 13 Nov 2020 16:47:40 +0000 (17:47 +0100)]
gcov: Add -fprofile-info-section support

Register the profile information in the specified section instead of using a
constructor/destructor.  A pointer to the profile information generated by
-fprofile-arcs or -ftest-coverage is placed in the specified section for each
translation unit.  This option disables the profile information registration
through a constructor and it disables the profile information processing
through a destructor.

I am not sure how I can test this option.  One approach would be to assemble a
test file, then scan it and check that a .gcov_info section is present and no
__gcov_init() and __gcov_exit() calls are present.  Is there an example for
this in the test suite?

gcc/

* common.opt (fprofile-info-section): New.
* coverage.c (build_gcov_info_var_registration): New.
(coverage_obj_init): Evaluate profile_info_section and use
build_gcov_info_var_registration().
* doc/invoke.texi (fprofile-info-section): Document.
* opts.c (common_handle_option): Process fprofile-info-section
option.

gcc/testsuite/ChangeLog:

* gcc.dg/profile-info-section.c: New test.

4 years agotree-optimization/97838 - fix SLP leaf detection
Richard Biener [Mon, 16 Nov 2020 08:28:03 +0000 (09:28 +0100)]
tree-optimization/97838 - fix SLP leaf detection

This properly handles reduction PHI nodes with unrepresented
initial value as leaf in the SLP graph.

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

PR tree-optimization/97838
* tree-vect-slp.c (vect_slp_build_vertices): Properly handle
not backwards reachable cycles.
(vect_optimize_slp): Check a node is leaf before marking it
visited.

* gcc.dg/vect/pr97838.c: New testcase.

4 years agoPrefer bit-test over the jump table.
Martin Liska [Mon, 9 Nov 2020 13:26:04 +0000 (14:26 +0100)]
Prefer bit-test over the jump table.

gcc/ChangeLog:

PR tree-optimization/97736
* tree-switch-conversion.c (switch_decision_tree::analyze_switch_statement):
Prefer bit tests.

gcc/testsuite/ChangeLog:

PR tree-optimization/97736
* gcc.dg/tree-ssa/switch-1.c: Prefer bit tests.
* g++.dg/tree-ssa/pr97736.C: New test.

4 years agotree-optimization/97835 - fix step vector construction for SLP induction
Richard Biener [Mon, 16 Nov 2020 08:06:41 +0000 (09:06 +0100)]
tree-optimization/97835 - fix step vector construction for SLP induction

We're stripping conversions off access functions of inductions and
thus the step can be of different sign.  Fix bogus step CTORs by
converting the elements rather than the whole vector.

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

PR tree-optimization/97835
* tree-vect-loop.c (vectorizable_induction): Convert step
scalars rather than step vector.

* gcc.dg/vect/pr97835.c: New testcase.

4 years agotree-optimization/97830 - fix compare of incomplete type size in VN
Richard Biener [Mon, 16 Nov 2020 07:40:47 +0000 (08:40 +0100)]
tree-optimization/97830 - fix compare of incomplete type size in VN

This avoids passing NULL to expressions_equal_p.

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

PR tree-optimization/97830
* tree-ssa-sccvn.c (vn_reference_eq): Check for incomplete
types before comparing TYPE_SIZE.

* gcc.dg/pr97830.c: New testcase.

4 years agoPut PREFETCHW back to march=broadwell
Cui,Lili [Fri, 13 Nov 2020 06:20:31 +0000 (14:20 +0800)]
Put PREFETCHW back to march=broadwell

PREFETCHW should be both in march=broadwell and march=silvermont.
I move PREFETCHW from march=broadwell to march=silvermont in previous
patch.

gcc/ChangeLog:

* config/i386/i386.h: Add PREFETCHW to march=broadwell.
* doc/invoke.texi: Put PREFETCHW back to relation arch.

4 years agoDaily bump.
GCC Administrator [Mon, 16 Nov 2020 00:16:31 +0000 (00:16 +0000)]
Daily bump.

4 years agoMSP430: Fix inconsistent naming of hwmult libfuncs
Jozef Lawrynowicz [Sun, 15 Nov 2020 21:03:06 +0000 (21:03 +0000)]
MSP430: Fix inconsistent naming of hwmult libfuncs

The naming scheme used by GCC to reference MSP430 hardware multiply
library functions is inconsistent.

Sometimes the "GCC" names (e.g. mulsi2) are used, other times the
"MSPABI" names (e.g. __mspabi_mpyl) are used.

Also, sometimes an identifier for the hardware multiply support is
appended to the GCC name, when the functions are defined, but this is
not required.

This patch fixes those issues, so the names used to refer to the
hardware multiply library functions follow a consistent pattern.

gcc/ChangeLog:

* config/msp430/msp430.c (msp430_output_labelref): Don't process mspabi
hwmult library function names into GCC-style names.

libgcc/ChangeLog:

* config/msp430/lib2hw_mul.S: Omit _hw* suffix from GCC names for
hwmult library functions.

gcc/testsuite/ChangeLog:

* gcc.target/msp430/rtx-cost-Os-f5series.c: Adjust test to use new
hwmult library function name.

4 years agoMSP430: Define function to check 16-bit hwmult support
Jozef Lawrynowicz [Sun, 15 Nov 2020 21:02:58 +0000 (21:02 +0000)]
MSP430: Define function to check 16-bit hwmult support

gcc/ChangeLog:

* config/msp430/msp430.c (msp430_use_16bit_hwmult): New.
(use_32bit_hwmult): Rename to..
(msp430_use_32bit_hwmult): ..this.
(msp430_muldiv_costs): Use msp430_use_16bit_hwmult and
msp430_use_32bit_hwmult.
(msp430_expand_helper): Use msp430_use_16bit_hwmult and
msp430_use_32bit_hwmult.
(msp430_output_labelref): Use msp430_use_32bit_hwmult.

4 years agotestsuite: fix ipa/modref-2.c on ilp32
David Edelsohn [Sun, 15 Nov 2020 19:56:47 +0000 (14:56 -0500)]
testsuite: fix ipa/modref-2.c on ilp32

ipa/modref-2.c output for Parm 1 depends on the word size.  This patch
updates the testcase to expect the appropriate result for ilp32 and lp64.

gcc/testsuite/ChangeLog:

* gcc.dg/ipa/modref-2.c: Add ilp32 expected result.

4 years agotestsuite: Update scanning symbol sections to support AIX.
David Edelsohn [Sun, 15 Nov 2020 02:10:25 +0000 (21:10 -0500)]
testsuite: Update scanning symbol sections to support AIX.

gcc/testsuite:

* lib/scanasm.exp (parse_section_of_symbols): Also look for AIX
XCOFF CSECT notation.
* g++.dg/opt/const4.C: Also look for AIX XCOFF "[RO]".
* gcc.dg/20021029-1.c: Likewise.
* gcc.dg/array-quals-1.c: Likewise and "[RW]".
* g++.dg/gomp/tls-5.C: Also look for AIX XCOFF "[TL]".
* gcc.dg/pr25376.c: Accept AIX decoration around named section
and function descriptor.

4 years agoVAX: Use `rtx_code' to hold the RTL expression code in `vax_rtx_costs'
Maciej W. Rozycki [Sun, 15 Nov 2020 17:41:52 +0000 (17:41 +0000)]
VAX: Use `rtx_code' to hold the RTL expression code in `vax_rtx_costs'

Use `enum rtx_code' rather than `int' to hold the the RTL expression
code in `vax_rtx_costs', matching the type these codes have been defined
with and making debugging just a tiny little bit easier.

gcc/
* config/vax/vax.c (vax_rtx_costs): Use `rtx_code' rather than
`int' for `code'.

4 years agoVAX/testsuite: Fix compilation options for `bswapdi-1.c'
Maciej W. Rozycki [Sun, 15 Nov 2020 17:41:52 +0000 (17:41 +0000)]
VAX/testsuite: Fix compilation options for `bswapdi-1.c'

Correct a regression in `vax-netbsdelf' gcc testing:

.../gcc/testsuite/gcc.target/vax/bswapdi-1.c: In function '__bswapdi2':
.../gcc/testsuite/gcc.target/vax/bswapdi-1.c:5:19: error: use of C99 long long integer constant [-Wlong-long]
.../gcc/testsuite/gcc.target/vax/bswapdi-1.c:6:14: error: use of C99 long long integer constant [-Wlong-long]
.../gcc/testsuite/gcc.target/vax/bswapdi-1.c:7:14: error: use of C99 long long integer constant [-Wlong-long]
.../gcc/testsuite/gcc.target/vax/bswapdi-1.c:8:14: error: use of C99 long long integer constant [-Wlong-long]
.../gcc/testsuite/gcc.target/vax/bswapdi-1.c:9:14: error: use of C99 long long integer constant [-Wlong-long]
.../gcc/testsuite/gcc.target/vax/bswapdi-1.c:10:14: error: use of C99 long long integer constant [-Wlong-long]
.../gcc/testsuite/gcc.target/vax/bswapdi-1.c:11:14: error: use of C99 long long integer constant [-Wlong-long]
.../gcc/testsuite/gcc.target/vax/bswapdi-1.c:12:14: error: use of C99 long long integer constant [-Wlong-long]
compiler exited with status 1
FAIL: gcc.target/vax/bswapdi-1.c (test for excess errors)

which is due to the defaults from `vax.exp':

# If a testcase doesn't have special options, use these.
global DEFAULT_CFLAGS
if ![info exists DEFAULT_CFLAGS] then {
    set DEFAULT_CFLAGS " -ansi -pedantic-errors"
}

Use an empty override then as the options used do not matter for the
objective of this test case.

gcc/testsuite/
* gcc.target/vax/bswapdi-1.c (dg-options): New setting.

4 years agoVAX: Fix a typo in NO_EXTERNAL_INDIRECT_ADDRESS
Maciej W. Rozycki [Sun, 15 Nov 2020 17:41:52 +0000 (17:41 +0000)]
VAX: Fix a typo in NO_EXTERNAL_INDIRECT_ADDRESS

Fix a typo in a NO_EXTERNAL_INDIRECT_ADDRESS macro check around an
assertion verifying DImode addition operands to be valid for PIC.

gcc/
* config/vax/vax.c (vax_output_int_add) <E_DImode>: Fix a typo
in NO_EXTERNAL_INDIRECT_ADDRESS.

4 years agoVAX: Correct a typo in PIC symbolic addition operand checks
Maciej W. Rozycki [Sun, 15 Nov 2020 17:41:52 +0000 (17:41 +0000)]
VAX: Correct a typo in PIC symbolic addition operand checks

Fix a typo and check both SImode addition operands for being incorrectly
symbolic in PIC mode before issuing a diagnostic dump of the offending
RTL expression.

gcc/
* config/vax/vax.c (vax_output_int_add) <E_SImode>: Also check
`operands[2]' for being symbolic with PIC rather than checking
`operands[1]' twice.

4 years agoc++: Check abstract type only on object creation. [PR86252]
Jason Merrill [Fri, 13 Nov 2020 21:33:50 +0000 (16:33 -0500)]
c++: Check abstract type only on object creation. [PR86252]

Abstract checking has been problematic for a while; when I implemented an
earlier issue resolution to do more checking it led to undesirable
instantiations, and so backed some of it out.  During the C++20 process we
decided with P0929R2 that we should go the other way, and only check
abstractness when we're actually creating an object, not when merely forming
an array or function type.  This means that we can remove the machinery for
checking whether a newly complete class makes some earlier declaration
ill-formed.  This change was moved as a DR, so I'm applying it to all
standard levels.  This could be reconsidered if it causes problems, but I
don't expect it to.

The change to the libstdc++ result_of test brings the expected behavior in
line with that for incomplete types, but as in PR97841 I think the libstdc++
handling of incomplete types in this and other type_traits is itself wrong,
so I expect these lines and others to change again before long.

gcc/cp/ChangeLog:

* decl.c (cp_finish_decl): Only check abstractness on definition.
(require_complete_types_for_parms): Check abstractness here.
(create_array_type_for_decl): Not here.
(grokdeclarator, grokparms, complete_vars): Not here.
* pt.c (tsubst, tsubst_arg_types, tsubst_function_type): Not here.
* typeck2.c (struct pending_abstract_type): Remove.
(struct abstract_type_hasher): Remove.
(abstract_pending_vars, complete_type_check_abstract): Remove.
(abstract_virtuals_error_sfinae): Handle arrays.
* call.c (conv_is_prvalue): Split out from...
(conv_binds_ref_to_prvalue): ...here.
(implicit_conversion_1): Rename from implicit_conversion.
(implicit_conversion): An abstract prvalue is bad.
(convert_like_internal): Don't complain if expr is already
error_mark_node.

gcc/testsuite/ChangeLog:

* g++.dg/other/abstract1.C: Adjust.
* g++.dg/other/abstract2.C: Adjust.
* g++.dg/other/abstract4.C: Adjust.
* g++.dg/other/abstract5.C: Adjust.
* g++.dg/other/abstract8.C: New test.
* g++.dg/template/sfinae-dr657.C: Adjust.
* g++.old-deja/g++.other/decl3.C: Adjust.

libstdc++-v3/ChangeLog:

* testsuite/20_util/result_of/sfinae_friendly_1.cc: Adjust.

4 years agoRemove duplicate vr_values::extract_range_builtin code.
Aldy Hernandez [Wed, 28 Oct 2020 15:05:01 +0000 (16:05 +0100)]
Remove duplicate vr_values::extract_range_builtin code.

Now that we know the vr_values and ranger versions are in sync, it is
safe to remove the vr_values version and just call the ranger one.

I am leaving the UBSAN bits in place since they make use of
relationals which are still not implemented in the ranger.

gcc/ChangeLog:

* vr-values.c (vr_values::extract_range_builtin): Rename to...
(vr_values::extract_range_from_ubsan_builtin): ...this.
Remove everything but UBSAN code.
(vr_values::extract_range_basic): Call ranger version for
everything except UBSAN built-ins.
* vr-values.h (class vr_values): Rename extract_range_builtin to
extract_range_from_ubsan_builtin.

4 years agoDo not put reload insns in the last empty BB.
Vladimir N. Makarov [Sun, 15 Nov 2020 16:22:19 +0000 (11:22 -0500)]
Do not put reload insns in the last empty BB.

gcc/
* lra.c (lra_process_new_insns): Don't put reload insns in the
last empty BB.

4 years agoMare return to clear EAF_UNUSED flag.
Jan Hubicka [Sun, 15 Nov 2020 14:10:22 +0000 (15:10 +0100)]
Mare return to clear EAF_UNUSED flag.

gcc/ChangeLog:
* ipa-modref.c (analyze_ssa_name_flags): Make return to clear
EAF_UNUSED flag.

gcc/testsuite/ChangeLog:
* gcc.c-torture/execute/pr97836.c: New test.

4 years agoDaily bump.
GCC Administrator [Sun, 15 Nov 2020 00:16:26 +0000 (00:16 +0000)]
Daily bump.

4 years agotestsuite, Objective-C : Amend PR23214 for Darwin11.
Iain Sandoe [Sat, 14 Nov 2020 21:16:37 +0000 (21:16 +0000)]
testsuite, Objective-C : Amend PR23214 for Darwin11.

The test needs to use Object rather than NSObject on this and earlier
OS versions. Although the PR reports against the GNU runtime, we run
this on NeXT as well.

gcc/testsuite/ChangeLog:

* objc.dg/pr23214.m: Use Object as the root object before
Darwin12 (and NSObject after).

4 years agoEscape parameters in gcc.dg/torture/pta-ptrarith-1.c
Jan Hubicka [Sat, 14 Nov 2020 12:53:55 +0000 (13:53 +0100)]
Escape parameters in gcc.dg/torture/pta-ptrarith-1.c

* gcc.dg/torture/pta-ptrarith-1.c: Escape parameters.

4 years agoDetect EAF flags in ipa-modref
Jan Hubicka [Sat, 14 Nov 2020 12:52:36 +0000 (13:52 +0100)]
Detect EAF flags in ipa-modref

A minimal patch for the EAF flags discovery.  It works only in local ipa-modref
and gives up on cyclic SSA graphs.  It improves pt_solution_includes
disambiguations twice.

gcc/Changelog:

* gimple.c: Include ipa-modref-tree.h and ipa-modref.h.
(gimple_call_arg_flags): Use modref to determine flags.
* ipa-modref.c: Include gimple-ssa.h, tree-phinodes.h,
tree-ssa-operands.h, stringpool.h and tree-ssanames.h.
(analyze_ssa_name_flags): Declare.
(modref_summary::useful_p): Summary is also useful if arg flags are
known.
(dump_eaf_flags): New function.
(modref_summary::dump): Use it.
(get_modref_function_summary): Be read for current_function_decl
being NULL.
(memory_access_to): New function.
(deref_flags): New function.
(call_lhs_flags): New function.
(analyze_parms): New function.
(analyze_function): Use it.
* ipa-modref.h (struct modref_summary): Add arg_flags.
* doc/invoke.texi (ipa-modref-max-depth): Document.
* params.opt (ipa-modref-max-depth): New param.

4 years agodwarf2: Emit DW_TAG_unspecified_parameters even in late DWARF [PR97599]
Jakub Jelinek [Sat, 14 Nov 2020 08:14:19 +0000 (09:14 +0100)]
dwarf2: Emit DW_TAG_unspecified_parameters even in late DWARF [PR97599]

Aldy's PR71855 fix avoided emitting multiple redundant
DW_TAG_unspecified_parameters sub-DIEs of a single DIE by restricting
it to early dwarf only.  That unfortunately means if we need to emit
another DIE for the function (whether it is for LTO, or e.g. because of
IPA cloning), we don't emit DW_TAG_unspecified_parameters, it remains
solely in the DW_AT_abstract_origin's referenced DIE.
But DWARF consumers don't really use DW_TAG_unspecified_parameters
from there, like we duplicate DW_TAG_formal_parameter sub-DIEs even in the
clones because either they have some more specific location, or e.g.
a function clone could have fewer or different argument types etc.,
they need to assume that originally stdarg function isn't later stdarg etc.
Unfortunately, while for DW_TAG_formal_parameter sub-DIEs, we can use the
hash tabs to look the PARM_DECLs if we already have the DIEs, for
DW_TAG_unspecified_parameters we don't have an easy way to look it up.

The following patch handles it by trying to figure out if we are creating a
fresh new DIE (in that case we add DW_TAG_unspecified_parameters if it is
stdarg), or if gen_subprogram_die is called again on an pre-existing DIE
to fill in some further details (then it will not touch it).

Except for lto, subr_die != old_die would be good enough, but unfortunately
for LTO the new DIE that will refer to early dwarf created DIE is created
on the fly during lookup_decl_die.  So the patch tracks if the DIE has
no children before any children are added to it.

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

PR debug/97599
* dwarf2out.c (gen_subprogram_die): Call
gen_unspecified_parameters_die even if not early dwarf, but only
if subr_die is a newly created DIE.

4 years agoSimplify testing symbol sections
Matthew Glazar [Sat, 14 Nov 2020 04:59:05 +0000 (23:59 -0500)]
Simplify testing symbol sections

gcc/testsuite

* lib/scanasm.exp (dg-scan): Extract file globbing code ...
(dg_glob_remote): ... into this new procedure.
(scan-assembler-symbol-section): Define.
(scan-symbol-section): Define.
* g++.dg/gomp/tls-5.C: Add symbol section test.
* g++.dg/opt/const4.C: Likewise.
* gcc.dg/20021029-1.c: Likewise.
* gcc.dg/array-quals-1.c: Likewise.
* gcc.dg/darwin-sections.c: Likewise.
* gcc.dg/pr25376.c: Likewise.
* gcc.test-framework/test-framework.exp: Load scanasm and test .S files.
* gcc.test-framework/dg-scan-symbol-section-1-exp-F.S: New test.
* gcc.test-framework/dg-scan-symbol-section-2-exp-F.S: New test.
* gcc.test-framework/dg-scan-symbol-section-3-exp-F.S: New test.
* gcc.test-framework/dg-scan-symbol-section-exp-P.S: New test.

4 years agoPR target/97682 - Fix to reuse t1 register between call address and epilogue.
Monk Chiang [Sat, 14 Nov 2020 03:35:11 +0000 (19:35 -0800)]
PR target/97682 - Fix to reuse t1 register between call address and epilogue.

  - When expanding the call pattern, choose t1 register be a jump register.
    Epilogue also uses a t1 register to adjust Stack point. The call pattern
    and epilogue will initial t1 twice, if both are generated in the same
    function. The call pattern will emit 'la t1,symbol' and 'jalr t1'instructions.
    Epilogue also emits 'li t1,4096' and 'addi sp,sp,t1' instructions.
    But li and addi instructions will be placed between la and jalr instructions.
    The la instruction will be removed by some optimizations,
    because t1 register define twice, the first define instruction look
    likes duplicate.

  - To resolve this issue, Prologue and Epilogue use the t0 register
    be a temporary register, the call pattern use the t1 register be
    a temporary register.

gcc/
2020-11-13  Monk Chiang  <monk.chiang@sifive.com>

PR target/97682
* config/riscv/riscv.h (RISCV_PROLOGUE_TEMP_REGNUM): Change register
to t0.
(RISCV_CALL_ADDRESS_TEMP_REGNUM): New Marco, define t1 register.
(RISCV_CALL_ADDRESS_TEMP): Use it for call instructions.
* config/riscv/riscv.c (riscv_legitimize_call_address): Use
RISCV_CALL_ADDRESS_TEMP.
(riscv_compute_frame_info): Change temporary register to t0 form t1.
(riscv_trampoline_init): Adjust comment.

gcc/testsuite/
2020-11-13  Monk Chiang  <monk.chiang@sifive.com>

PR target/97682
* g++.target/riscv/pr97682.C: New test.
* gcc.target/riscv/interrupt-3.c: Check register for t0.
* gcc.target/riscv/interrupt-4.c: Likewise.

4 years agoAsan changes for RISC-V.
Jim Wilson [Sat, 14 Nov 2020 02:12:24 +0000 (18:12 -0800)]
Asan changes for RISC-V.

We have only riscv64 asan support, there is no riscv32 support as yet.  So I
need to be able to conditionally enable asan support for the riscv target.  I
implemented this by returning zero from the asan_shadow_offset function.  This
requires a change to toplev.c and docs in target.def.

gcc/
* config/riscv/riscv.c (riscv_asan_shadow_offset): New.
(TARGET_ASAN_SHADOW_OFFSET): New.
* doc/tm.texi: Regenerated.
* target.def (asan_shadow_offset); Mention that it can return zero.
* toplev.c (process_options): Check for and handle zero return from
targetm.asan_shadow_offset call.

Co-Authored-By: cooper.joshua <cooper.joshua@linux.alibaba.com>
4 years agoopenmp: Add support for non-VLA {,first}private allocate on omp task
Jakub Jelinek [Sat, 14 Nov 2020 00:46:16 +0000 (01:46 +0100)]
openmp: Add support for non-VLA {,first}private allocate on omp task

This patch adds support for custom allocators on private/firstprivate
clauses for task (and taskloop) constructs.  Private didn't need anything
special, but firstprivate if it is passed by reference needs the GOMP_alloc
calls in the copyfn and GOMP_free in the task body.

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

* gimplify.c (gimplify_omp_for): Add OMP_CLAUSE_ALLOCATE_ALLOCATOR
decls as firstprivate on task clauses even when allocate clause
decl is not lastprivate.
* omp-low.c (install_var_field): Don't dereference omp_is_reference
types if mask is 33 rather than 1.
(scan_sharing_clauses): Populate allocate_map even for task
constructs.  For now remove it back for variables mentioned in
reduction and in_reduction clauses on task/taskloop constructs
or on VLA task firstprivates.  For firstprivate on task construct,
install the var field into field_map with by_ref and 33 instead
of false and 1 if mentioned in allocate clause.
(lower_private_allocate): Set TREE_THIS_NOTRAP on the created
MEM_REF.
(lower_rec_input_clauses): Handle allocate for task firstprivatized
non-VLA variables.
(create_task_copyfn): Likewise.

* testsuite/libgomp.c-c++-common/allocate-1.c (struct S): New type.
(foo): Add tests for non-VLA private and firstprivate clauses on
omp task.
(bar): Likewise.  Remove taking of address from private/firstprivate
variables.
* testsuite/libgomp.c++/allocate-1.C (struct S): New type.
(foo): Add p, q, px and s arguments.  Add tests for array reductions
and for non-VLA private and firstprivate clauses on omp task.
(bar): Removed.
(main): Adjust foo caller.  Don't call bar.

4 years agoDaily bump.
GCC Administrator [Sat, 14 Nov 2020 00:16:38 +0000 (00:16 +0000)]
Daily bump.

4 years agolibstdc++: Use custom timespec in system calls [PR 93421]
Jonathan Wakely [Thu, 24 Sep 2020 16:35:52 +0000 (17:35 +0100)]
libstdc++: Use custom timespec in system calls [PR 93421]

On 32-bit targets where userspace has switched to 64-bit time_t, we
cannot pass struct timespec to SYS_futex or SYS_clock_gettime, because
the userspace definition of struct timespec will not match what the
kernel expects.

We use the existence of the SYS_futex_time64 or SYS_clock_gettime_time64
macros to imply that userspace *might* have switched to the new timespec
definition.  This is a conservative assumption. It's possible that the
new syscall numbers are defined in the libc headers but that timespec
hasn't been updated yet (as is the case for glibc currently). But using
the alternative struct with two longs is still OK, it's just redundant
if userspace timespec still uses a 32-bit time_t.

We also check that SYS_futex_time64 != SYS_futex so that we don't try
to use a 32-bit tv_sec on modern targets that only support the 64-bit
system calls and define the old macro to the same value as the new one.

We could possibly check #ifdef __USE_TIME_BITS64 to see whether
userspace has actually been updated, but it's not clear if user code
is meant to inspect that or if it's only for libc internal use.

libstdc++-v3/ChangeLog:

PR libstdc++/93421
* src/c++11/chrono.cc [_GLIBCXX_USE_CLOCK_GETTIME_SYSCALL]
(syscall_timespec): Define a type suitable for SYS_clock_gettime
calls.
(system_clock::now(), steady_clock::now()): Use syscall_timespec
instead of timespec.
* src/c++11/futex.cc (syscall_timespec): Define a type suitable
for SYS_futex and SYS_clock_gettime calls.
(relative_timespec): Use syscall_timespec instead of timespec.
(__atomic_futex_unsigned_base::_M_futex_wait_until): Likewise.
(__atomic_futex_unsigned_base::_M_futex_wait_until_steady):
Likewise.

4 years agolibstdc++: Remove redundant overflow check for futex timeout [PR 93456]
Jonathan Wakely [Fri, 13 Nov 2020 20:57:15 +0000 (20:57 +0000)]
libstdc++: Remove redundant overflow check for futex timeout [PR 93456]

The relative_timespec function already checks for the case where the
specified timeout is in the past, so the difference can never be
negative. That means we dn't need to check if it's more negative than
the minimum time_t value.

libstdc++-v3/ChangeLog:

PR libstdc++/93456
* src/c++11/futex.cc (relative_timespec): Remove redundant check
negative values.
* testsuite/30_threads/future/members/wait_until_overflow.cc: Moved to...
* testsuite/30_threads/future/members/93456.cc: ...here.

4 years agoc: C2x binary constants
Joseph Myers [Fri, 13 Nov 2020 22:45:22 +0000 (22:45 +0000)]
c: C2x binary constants

C2x adds binary integer constants (approved at the last WG14 meeting,
though not yet added to the working draft in git).  Configure libcpp
to consider these a standard feature in C2x mode, with appropriate
updates to diagnostics including support for diagnosing them with
-std=c2x -Wc11-c2x-compat.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/testsuite/
2020-11-13  Joseph Myers  <joseph@codesourcery.com>

* gcc.dg/binary-constants-2.c, gcc.dg/binary-constants-3.c,
gcc.dg/system-binary-constants-1.c: Update expected diagnostics.
* gcc.dg/c11-binary-constants-1.c,
gcc.dg/c11-binary-constants-2.c, gcc.dg/c2x-binary-constants-1.c,
gcc.dg/c2x-binary-constants-2.c, gcc.dg/c2x-binary-constants-3.c:
New tests.

libcpp/
2020-11-13  Joseph Myers  <joseph@codesourcery.com>

* expr.c (cpp_classify_number): Update diagnostic for binary
constants for C.  Also diagnose binary constants for
-Wc11-c2x-compat.
* init.c (lang_defaults): Enable binary constants for GNUC2X and
STDC2X.

4 years agoRevert accidental commit
Jan Hubicka [Fri, 13 Nov 2020 22:32:02 +0000 (23:32 +0100)]
Revert accidental commit

* tree-ssa-alias.c (ao_ref_base_alias_ptr_type): Remove accidental
commit.
(ao_ref_alias_ptr_type): Remove accidental commit.

4 years agotestsuite: guality/redeclaration1.C test workaround
Jakub Jelinek [Fri, 13 Nov 2020 22:27:23 +0000 (23:27 +0100)]
testsuite: guality/redeclaration1.C test workaround

Apparently older GDB versions didn't handle this test right and so while
it has been properly printing 42 on line 14 (e.g. on x86_64), it issued
a weird error on line 17 (and because it didn't print any value, guality
testsuite wasn't marking it as FAIL).
That has been apparently fixed in GDB 10, where it now (on x86_64) prints
properly.
Unfortunately that revealed that the test can suffer from instruction
scheduling, where e.g. on i686 (but various other arches) the very first
insn of the function (or whatever b 14 is on) happens to be load of the
S::i variable from memory and that insn has the inner lexical scope, so
GDB 10 prints there 24 instead of 42.  The following insn is then
the first store to l and there the automatic i is in scope and prints as 42
and then the second store to l where the inner lexical scope is current
and prints 24 again.
The test wasn't meant about insn scheduling but about whether we emit the
DIEs properly, so this hack attempts to prevent the undesirable scheduling.

2020-11-13  Jakub Jelinek  <jakub@redhat.com>

* g++.dg/guality/redeclaration1.C (p): New variable.
(S::f): Increment what p points to before storing S::i into l.  Adjust
gdb-test line numbers.
(main): Initialize p to address of an automatic variable.

4 years agoc++: Predefine __STDCPP_THREADS__ in the compiler if thread model is not single ...
Jakub Jelinek [Fri, 13 Nov 2020 22:23:33 +0000 (23:23 +0100)]
c++: Predefine __STDCPP_THREADS__ in the compiler if thread model is not single [PR63287]

The following patch predefines __STDCPP_THREADS__ macro to 1 if c++11 or
later and thread model (e.g. printed by gcc -v) is not single.
There are two targets not handled by this patch, those that define
THREAD_MODEL_SPEC.  In one case - QNX - it looks just like a mistake
to me, instead of setting thread_model=posix in config.gcc it uses
THREAD_MODEL_SPEC macro to set it unconditionally to posix.
The other is hpux10, which uses -threads option to decide if threads
are enabled or not, but that option isn't really passed to the compiler.
I think that is something that really should be solved in config/pa/
instead, e.g. in the config/xxx/xxx-c.c targets usually set their own
predefined macros and it could handle this, and either pass the option
also to the compiler, or say predefine __STDCPP_THREADS__ if _DCE_THREADS
macro is defined already (or -D_DCE_THREADS found on the command line),
or whatever else.

2020-11-13  Jakub Jelinek  <jakub@redhat.com>

PR c++/63287
* c-cppbuiltin.c: Include configargs.h.
(c_cpp_builtins): For C++11 and later if THREAD_MODEL_SPEC is not
defined, predefine __STDCPP_THREADS__ to 1 unless thread_model is
"single".

4 years agoIn 'gcc/omp-oacc-kernels-decompose.cc', use langhook instead of accessing language...
Kwok Cheung Yeung [Mon, 5 Aug 2019 21:51:22 +0000 (22:51 +0100)]
In 'gcc/omp-oacc-kernels-decompose.cc', use langhook instead of accessing language-specific decl information

gcc/
* omp-oacc-kernels-decompose.cc (maybe_build_inner_data_region):
Use langhook instead of accessing language-specific decl
information.

4 years agoDecompose OpenACC 'kernels' constructs into parts, a sequence of compute constructs
Gergö Barany [Thu, 31 Jan 2019 23:59:30 +0000 (00:59 +0100)]
Decompose OpenACC 'kernels' constructs into parts, a sequence of compute constructs

Not yet enabled by default: for now, the current mode of OpenACC 'kernels'
constructs handling still remains '-fopenacc-kernels=parloops', but that is to
change later.

gcc/
* omp-oacc-kernels-decompose.cc: New.
* Makefile.in (OBJS): Add it.
* passes.def: Instantiate it.
* tree-pass.h (make_pass_omp_oacc_kernels_decompose): Declare.
* flag-types.h (enum openacc_kernels): Add.
* doc/invoke.texi (-fopenacc-kernels): Document.
* gimple.h (enum gf_mask): Add
'GF_OMP_TARGET_KIND_OACC_PARALLEL_KERNELS_PARALLELIZED',
'GF_OMP_TARGET_KIND_OACC_PARALLEL_KERNELS_GANG_SINGLE',
'GF_OMP_TARGET_KIND_OACC_DATA_KERNELS'.
(is_gimple_omp_oacc, is_gimple_omp_offloaded): Handle these.
* gimple-pretty-print.c (dump_gimple_omp_target): Likewise.
* omp-expand.c (expand_omp_target, build_omp_regions_1)
(omp_make_gimple_edges): Likewise.
* omp-low.c (scan_sharing_clauses, scan_omp_for)
(check_omp_nesting_restrictions, lower_oacc_reductions)
(lower_oacc_head_mark, lower_omp_target): Likewise.
* omp-offload.c (execute_oacc_device_lower): Likewise.
gcc/c-family/
* c.opt (fopenacc-kernels): Add.
gcc/fortran/
* lang.opt (fopenacc-kernels): Add.
gcc/testsuite/
* c-c++-common/goacc/kernels-decompose-1.c: New.
* c-c++-common/goacc/kernels-decompose-2.c: New.
* c-c++-common/goacc/kernels-decompose-ice-1.c: New.
* c-c++-common/goacc/kernels-decompose-ice-2.c: New.
* gfortran.dg/goacc/kernels-decompose-1.f95: New.
* gfortran.dg/goacc/kernels-decompose-2.f95: New.
* c-c++-common/goacc/if-clause-2.c: Adjust.
* gfortran.dg/goacc/kernels-tree.f95: Likewise.
libgomp/
* testsuite/libgomp.oacc-c-c++-common/declare-vla-kernels-decompose-ice-1.c:
New.
* testsuite/libgomp.oacc-c-c++-common/declare-vla-kernels-decompose.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-decompose-1.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/declare-vla.c: Adjust.
* testsuite/libgomp.oacc-fortran/pr94358-1.f90: Likewise.

Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
4 years agoMore explicit checking of which OMP constructs we're expecting
Thomas Schwinge [Tue, 13 Oct 2020 12:56:59 +0000 (14:56 +0200)]
More explicit checking of which OMP constructs we're expecting

In particular, more precisely highlight what applies generally vs. the special
handling for the current 'parloops'-based OpenACC 'kernels' implementation.

gcc/
* omp-low.c (scan_sharing_clauses, scan_omp_for)
(lower_oacc_reductions, lower_omp_target): More explicit checking
of which OMP constructs we're expecting.

4 years agoAttach an attribute to all outlined OpenACC compute regions
Thomas Schwinge [Wed, 28 Oct 2020 10:43:49 +0000 (11:43 +0100)]
Attach an attribute to all outlined OpenACC compute regions

This allows for making some things more explicit, later on.

gcc/
* omp-expand.c (expand_omp_target): Attach an attribute to all
outlined OpenACC compute regions.
* omp-offload.c (execute_oacc_device_lower): Adjust.
gcc/testsuite/
* c-c++-common/goacc/classify-parallel.c: Adjust.
* gfortran.dg/goacc/classify-parallel.f95: Likewise.
* c-c++-common/goacc/classify-serial.c: New.
* gfortran.dg/goacc/classify-serial.f95: Likewise.

4 years agoAdd 'libgomp.oacc-fortran/pr94358-1.f90' [PR94358]
Gergö Barany [Mon, 21 Jan 2019 11:08:57 +0000 (03:08 -0800)]
Add 'libgomp.oacc-fortran/pr94358-1.f90' [PR94358]

Document status quo re PR94358 "[OMP] Privatize internal array variables
introduced by the Fortran FE".

libgomp/
PR fortran/94358
* testsuite/libgomp.oacc-fortran/pr94358-1.f90: New.

Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
4 years agoc++: Add feature test macro for C++20 using enum.
Jason Merrill [Fri, 13 Nov 2020 19:15:46 +0000 (14:15 -0500)]
c++: Add feature test macro for C++20 using enum.

Missing piece from the 'using enum' implementation patch.

gcc/c-family/ChangeLog:

* c-cppbuiltin.c (c_cpp_builtins): Define __cpp_using_enum.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/feat-cxx2a.C: Check it.

4 years agoFix modref insertion hook.
Jan Hubicka [Fri, 13 Nov 2020 20:15:40 +0000 (21:15 +0100)]
Fix modref insertion hook.

* ipa-modref.c (modref_summaries::insert,
modref_summaries_lto::insert): Remove summary if ipa-modref is disabled.

4 years agoCopied arguments are readonly
Jan Hubicka [Fri, 13 Nov 2020 20:13:51 +0000 (21:13 +0100)]
Copied arguments are readonly

* attr-fnspec.h (attr_fnspec::arg_readonly_p): Accept '1'...'9'.

4 years agolibstdc++: Avoid more 32-bit time_t overflows in futex calls
Jonathan Wakely [Fri, 13 Nov 2020 19:11:02 +0000 (19:11 +0000)]
libstdc++: Avoid more 32-bit time_t overflows in futex calls

This fixes another overflow in code converting a std::chrono::seconds
duration to a time_t. This time in the new code using a futex wait with
an absolute timeout (so this one doesn't need to be backported to the
release branches).

A timeout after the epochalypse would overflow the tv_sec field,
producing an incorrect value. If that incorrect value happened to be
negative, the syscall would return with EINVAL and then the caller would
keep retrying, spinning until the timeout was reached.  If the value
happened to be positive, we would wake up too soon and incorrectly
report a timeout

libstdc++-v3/ChangeLog:

* src/c++11/futex.cc (relative_timespec): Add [[unlikely]]
attributes.
(__atomic_futex_unsigned_base::_M_futex_wait_until)
(__atomic_futex_unsigned_base::_M_futex_wait_until_steady):
Check for overflow.
* testsuite/30_threads/future/members/wait_until_overflow.cc:
New test.

4 years agoClarify the documentation for the ms_abi fucntion attribute
Peter Jones [Fri, 13 Nov 2020 19:07:45 +0000 (12:07 -0700)]
Clarify the documentation for the ms_abi fucntion attribute

gcc/

* doc/extend.texi: Clarify the documentation for the ms_abi
function attribute.

4 years agoRe: Fix gimple_expr_code?
Andrew MacLeod [Fri, 13 Nov 2020 18:56:01 +0000 (13:56 -0500)]
Re: Fix gimple_expr_code?

have gimple_expr_code return the correct code for GIMPLE_ASSIGN.
use gassign and gcond in gimple_range_handler.

* gimple-range.h (gimple_range_handler): Cast to gimple stmt
kinds before asking for code and type.
* gimple.h (gimple_expr_code): Call gassign and gcond routines
to get their expr_code.

4 years agolibiberty: Support the new ("v0") mangling scheme in rust-demangle
Eduard-Mihai Burtescu [Fri, 13 Nov 2020 18:55:45 +0000 (18:55 +0000)]
libiberty: Support the new ("v0") mangling scheme in rust-demangle

This is the libiberty (mainly for binutils/gdb) counterpart of
https://github.com/alexcrichton/rustc-demangle/pull/23.

Relevant links for the new Rust mangling scheme (aka "v0"):
* Rust RFC: https://github.com/rust-lang/rfcs/pull/2603
* tracking issue: https://github.com/rust-lang/rust/issues/60705
* implementation: https://github.com/rust-lang/rust/pull/57967

This implementation includes full support for UTF-8 identifiers
via punycode, so I've included a testcase for that as well.

libiberty/ChangeLog:
* rust-demangle.c (struct rust_demangler): Add
skipping_printing and bound_lifetime_depth fields.
(eat): Add (v0-only).
(parse_integer_62): Add (v0-only).
(parse_opt_integer_62): Add (v0-only).
(parse_disambiguator): Add (v0-only).
(struct rust_mangled_ident): Add punycode{,_len} fields.
(parse_ident): Support v0 identifiers.
(print_str): Respect skipping_printing.
(print_uint64): Add (v0-only).
(print_uint64_hex): Add (v0-only).
(print_ident): Respect skipping_printing,
Support v0 identifiers.
(print_lifetime_from_index): Add (v0-only).
(demangle_binder): Add (v0-only).
(demangle_path): Add (v0-only).
(demangle_generic_arg): Add (v0-only).
(demangle_type): Add (v0-only).
(demangle_path_maybe_open_generics): Add (v0-only).
(demangle_dyn_trait): Add (v0-only).
(demangle_const): Add (v0-only).
(demangle_const_uint): Add (v0-only).
(basic_type): Add (v0-only).
(rust_demangle_callback): Support v0 symbols.
* testsuite/rust-demangle-expected: Add v0 testcases.

4 years agoMake strstr.c in libiberty ANSI compliant
Seija Kijin [Fri, 13 Nov 2020 18:51:27 +0000 (11:51 -0700)]
Make strstr.c in libiberty ANSI compliant

libiberty/

* strstr.c (strstr): Make implementation ANSI/POSIX compliant.

4 years agoc++: Implement C++20 'using enum'. [PR91367]
Jason Merrill [Tue, 10 Nov 2020 22:17:19 +0000 (17:17 -0500)]
c++: Implement C++20 'using enum'.  [PR91367]

This feature allows the programmer to import enumerator names into the
current scope so later mentions don't need to use the fully-qualified name.
These usings are not subject to the usual restrictions on using-decls: in
particular, they can move between class and non-class scopes, and between
classes that are not related by inheritance.  This last caused difficulty
for our normal approach to using-decls within a class hierarchy, as we
assume that the class where we looked up a used declaration is derived from
the class where it was first declared.  So to simplify things, in that case
we make a clone of the CONST_DECL in the using class.

Thanks to Nathan for the start of this work: in particular, the
lookup_using_decl rewrite.

The changes to dwarf2out revealed an existing issue with the D front-end: we
were doing the wrong thing for importing a D CONST_DECL, because
dwarf2out_imported_module_or_decl_1 was looking through it to its type,
expecting it to be an enumerator, but in one case in thread.d, the constant
had type int.  Adding the ability to import a C++ enumerator also fixed
that, but that led to a crash in force_decl_die, which didn't know what to
do with a CONST_DECL.  So now it does.

Co-authored-by: Nathan Sidwell <nathan@acm.org>
gcc/cp/ChangeLog:

* cp-tree.h (USING_DECL_UNRELATED_P): New.
(CONST_DECL_USING_P): New.
* class.c (handle_using_decl): If USING_DECL_UNRELATED_P,
clone the CONST_DECL.
* name-lookup.c (supplement_binding_1): A clone hides its
using-declaration.
(lookup_using_decl): Rewrite to separate lookup and validation.
(do_class_using_decl): Adjust.
(finish_nonmember_using_decl): Adjust.
* parser.c (make_location): Add cp_token overload.
(finish_using_decl): Split out from...
(cp_parser_using_declaration): ...here.  Don't look through enums.
(cp_parser_using_enum): New.
(cp_parser_block_declaration): Call it.
(cp_parser_member_declaration): Call it.
* semantics.c (finish_id_expression_1): Handle enumerator
used from class scope.

gcc/ChangeLog:

* dwarf2out.c (gen_enumeration_type_die): Call
equate_decl_number_to_die for enumerators.
(gen_member_die): Don't move enumerators to their
enclosing class.
(dwarf2out_imported_module_or_decl_1): Allow importing
individual enumerators.
(force_decl_die): Handle CONST_DECL.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/inh-ctor28.C: Adjust expected diagnostic.
* g++.dg/cpp0x/inh-ctor33.C: Likewise.
* g++.dg/cpp0x/using-enum-1.C: Add comment.
* g++.dg/cpp0x/using-enum-2.C: Allowed in C++20.
* g++.dg/cpp0x/using-enum-3.C: Likewise.
* g++.dg/cpp1z/class-deduction69.C: Adjust diagnostic.
* g++.dg/inherit/using5.C: Likewise.
* g++.dg/cpp2a/using-enum-1.C: New test.
* g++.dg/cpp2a/using-enum-2.C: New test.
* g++.dg/cpp2a/using-enum-3.C: New test.
* g++.dg/cpp2a/using-enum-4.C: New test.
* g++.dg/cpp2a/using-enum-5.C: New test.
* g++.dg/cpp2a/using-enum-6.C: New test.
* g++.dg/debug/dwarf2/using-enum.C: New test.

4 years ago[PATCH] Implementation of asm goto outputs
Vladimir N. Makarov [Fri, 13 Nov 2020 17:45:59 +0000 (12:45 -0500)]
[PATCH] Implementation of asm goto outputs

gcc/
* cfgexpand.c (expand_asm_stmt): Output asm goto with outputs too.
Place insns after asm goto on edges.
* doc/extend.texi: Reflect the changes in asm goto documentation.
* gimple.c (gimple_build_asm_1): Remove an assert checking output
absence for asm goto.
* gimple.h (gimple_asm_label_op, gimple_asm_set_label_op): Take
possible asm goto outputs into account.
* ira.c (ira): Remove critical edges for potential asm goto output
reloads.
(ira_nullify_asm_goto): New function.
* ira.h (ira_nullify_asm_goto): New prototype.
* lra-assigns.c (lra_split_hard_reg_for): Use ira_nullify_asm_goto.
Check that splitting is done inside a basic block.
* lra-constraints.c (curr_insn_transform): Permit output reloads
for any jump insn.
* lra-spills.c (lra_final_code_change): Remove USEs added in ira
for asm gotos.
* lra.c (lra_process_new_insns): Place output reload insns after
jumps in the beginning of destination BBs.
* reload.c (find_reloads): Report error for asm gotos with
outputs.  Modify them to keep CFG consistency to avoid crashes.
* tree-into-ssa.c (rewrite_stmt): Don't put debug stmt after asm
goto.

gcc/c/
* c-parser.c (c_parser_asm_statement): Parse outputs for asm
goto too.
* c-typeck.c (build_asm_expr): Remove an assert checking output
absence for asm goto.

gcc/cp
* parser.c (cp_parser_asm_definition): Parse outputs for asm
goto too.

gcc/testsuite/
* c-c++-common/asmgoto-2.c: Permit output in asm goto.
* gcc.c-torture/compile/asmgoto-2.c: New.
* gcc.c-torture/compile/asmgoto-3.c: New.
* gcc.c-torture/compile/asmgoto-4.c: New.
* gcc.c-torture/compile/asmgoto-5.c: New.

4 years agoopenmp: Support allocate for C/C++ array section reductions
Jakub Jelinek [Fri, 13 Nov 2020 17:57:06 +0000 (18:57 +0100)]
openmp: Support allocate for C/C++ array section reductions

This adds allocate clause support for array section reductions.
Furthermore, it fixes one bug that would cause inscan reductions with
allocate to be rejected by C, and for now just ignores allocate for
inscan/task reductions, that will need slightly more work.

2020-11-13  Jakub Jelinek  <jakub@redhat.com>

gcc/
* omp-low.c (scan_sharing_clauses): For now remove for reduction
clauses with inscan or task modifiers decl from allocate_map.
(lower_private_allocate): Handle TYPE_P (new_var).
(lower_rec_input_clauses): Handle allocate clause for C/C++ array
reductions.
gcc/c/
* c-typeck.c (c_finish_omp_clauses): Don't clear
OMP_CLAUSE_REDUCTION_INSCAN unless reduction_seen == -2.
libgomp/
* testsuite/libgomp.c-c++-common/allocate-1.c (foo): Add tests
for array reductions.
(main): Adjust foo callers.

4 years agoipa-cp: One more safe_add (PR 97816)
Martin Jambor [Fri, 13 Nov 2020 17:30:11 +0000 (18:30 +0100)]
ipa-cp: One more safe_add (PR 97816)

The new behavior of safe_add triggered an ICE because of one use where
it had not been used instead of a simple addition.  I'll fix it with the
following obvious patch so that periodic benchmarkers can continue
working because a proper fix (see below) will need a review.

The testcase showed me, however, that we can propagate time and cost
from one lattice to another more than once even when that was not the
intent.  I'll address that as a follow-up after I verify it does not
affect the IPA-CP heuristics too much or change the corresponding
params accordingly.

Bootstrapped and tested on x86_64-linux.

gcc/ChangeLog:

2020-11-13  Martin Jambor  <mjambor@suse.cz>

PR ipa/97816
* ipa-cp.c (value_topo_info<valtype>::propagate_effects): Use
safe_add instead of a simple addition.

4 years agoDo not warn about unused macros while processing #pragma GCC optimize
Piotr H. Dabrowski [Fri, 13 Nov 2020 17:27:16 +0000 (12:27 -0500)]
Do not warn about unused macros while processing #pragma GCC optimize

libcpp

PR c++/91318
* include/cpplib.h: Added cpp_define_unused(), cpp_define_formatted_unused()
* directives.c: Likewise.

gcc/c-family

PR c++/91318
* c-cppbuiltin.c: c_cpp_builtins_optimize_pragma(): use cpp_define_unused()

4 years agolibstdc++: Avoid 32-bit time_t overflows in futex calls
Jonathan Wakely [Fri, 13 Nov 2020 15:19:04 +0000 (15:19 +0000)]
libstdc++: Avoid 32-bit time_t overflows in futex calls

The existing code doesn't check whether the chrono::seconds value is out
of range of time_t. When using a timeout before the epoch (with a
negative value) subtracting the current time (as time_t) and then
assigning it to a time_t can overflow to a large positive value. This
means that we end up waiting several years even though the specific
timeout was in the distant past.

We do have a check for negative timeouts, but that happens after the
conversion to time_t so happens after the overflow.

The conversion to a relative timeout is done in two places, so this
factors it into a new function and adds the overflow checks there.

libstdc++-v3/ChangeLog:

* src/c++11/futex.cc (relative_timespec): New function to
create relative time from two absolute times.
(__atomic_futex_unsigned_base::_M_futex_wait_until)
(__atomic_futex_unsigned_base::_M_futex_wait_until_steady):
Use relative_timespec.

4 years agoAdd 3 new EVRP testcases.
Andrew MacLeod [Fri, 13 Nov 2020 16:40:41 +0000 (11:40 -0500)]
Add 3 new EVRP testcases.

test new evrp functionality.

gcc/testsuite/
* gcc.dg/tree-ssa/evrp20.c
* gcc.dg/tree-ssa/evrp21.c
* gcc.dg/tree-ssa/evrp22.c

4 years agotestsuite: move expected error location
Martin Liska [Fri, 13 Nov 2020 16:38:41 +0000 (17:38 +0100)]
testsuite: move expected error location

gcc/testsuite/ChangeLog:

PR testsuite/97788
* g++.dg/ubsan/pr61272.C: Move expected error location.

4 years agolibsanitizer: update LOCAL_PATCHES.
Martin Liska [Fri, 13 Nov 2020 16:31:16 +0000 (17:31 +0100)]
libsanitizer: update LOCAL_PATCHES.

libsanitizer/ChangeLog:

* LOCAL_PATCHES: Update to the latest commit.

4 years agolibsanitizer: Apply local patches.
Martin Liska [Fri, 13 Nov 2020 16:21:45 +0000 (17:21 +0100)]
libsanitizer: Apply local patches.

4 years agolibsanitizer: merge from master.
Martin Liska [Fri, 13 Nov 2020 16:03:23 +0000 (17:03 +0100)]
libsanitizer: merge from master.

4 years agoMSP430: Skip index-1.c test
Jozef Lawrynowicz [Fri, 13 Nov 2020 15:36:01 +0000 (15:36 +0000)]
MSP430: Skip index-1.c test

To access the "n - 100000"th element of "a" in this test, GCC will
generate the following code for msp430-elf with -mcpu=msp430x:

  RLAM.W  #1, R12
  MOV.W a-3392(R12), R12

Since there aren't actually 100,000 elements in a, this means that
"a-3392" offset calculated by the linker can overflow, as the address of
"a" can validly be less than 3392.

The relocations used for -mcpu=msp430 and -mlarge are not as strict and
the calculated value is allowed to wrap around the address space,
avoiding relocation overflows.

gcc/testsuite/ChangeLog:

* gcc.c-torture/execute/index-1.c: Skip for the default MSP430 430X ISA.

4 years agoMSP430: Implement TARGET_INSN_COST
Jozef Lawrynowicz [Fri, 13 Nov 2020 15:35:52 +0000 (15:35 +0000)]
MSP430: Implement TARGET_INSN_COST

The length of an insn can be used to calculate its cost, when optimizing
for size. When optimizing for speed, this is a good estimate, since the
cycle cost of an MSP430 instruction increases with its length.

gcc/ChangeLog:

* config/msp430/msp430.c (TARGET_INSN_COST): Define.
(msp430_insn_cost): New function.
* config/msp430/msp430.h (BRANCH_COST): Define.
(LOGICAL_OP_NON_SHORT_CIRCUIT): Define.

gcc/testsuite/ChangeLog:

* gcc.target/msp430/rtx-cost-O3-default.c: New test.
* gcc.target/msp430/rtx-cost-O3-f5series.c: New test.
* gcc.target/msp430/rtx-cost-Os-default.c: New test.
* gcc.target/msp430/rtx-cost-Os-f5series.c: New test.

4 years agoMSP430: Add defaulting to the insn length attribute
Jozef Lawrynowicz [Fri, 13 Nov 2020 15:35:47 +0000 (15:35 +0000)]
MSP430: Add defaulting to the insn length attribute

The length of MSP430 instructions is mostly just a function of the type
and number of operands. Setting the "type" attribute on all insns
describes the number of operands, and the position of the source and
destination operands.

In most cases, defaulting in the "length" and "extension" attribute
definitions can then be used to calculate the total length of the
instruction by using the value of the "type" attribute to examine the
operands.

gcc/ChangeLog:

* config/msp430/msp430-protos.h (msp430x_extendhisi): Return int
instead of char *.
(msp430_output_asm_shift_insns): Likewise.
Add new return_length argument.
(msp430x_insn_required): Add prototype.
* config/msp430/msp430.c (msp430_output_asm_shift_insns): Return the
total length, in bytes, of the emitted instructions.
(msp430x_insn_required): New function.
(msp430x_extendhisi): Return the total length, in bytes, of the
emitted instructions.
* config/msp430/msp430.h (ADJUST_INSN_LENGTH): Define.
* config/msp430/msp430.md: New define_attr "type".
New define_attr "extension".
New define_attr "length_multiplier".
New define_attr "extra_length".
Rewrite define_attr "length".
Set type, extension, length, length_multiplier or extra_length insn
attributes on all insns, as appropriate.
(andneghi3): Rewrite using constraints instead of C code to decide
output insns.
* config/msp430/predicates.md (msp430_cheap_operand): New predicate.
(msp430_high_memory_operand): New predicate.

4 years agoMSP430: Implement TARGET_RTX_COSTS
Jozef Lawrynowicz [Fri, 13 Nov 2020 15:35:42 +0000 (15:35 +0000)]
MSP430: Implement TARGET_RTX_COSTS

Costs of MSP430 instructions are mostly just a function of the type and
number of operands; knowledge of the specific instruction often
isn't required to calculate the cost.
In these cases, TARGET_RTX_COSTS just needs to examine the operands to
calculate the cost of the expression.

For more complicated operations where library helper functions are
required, if the cost cannot be accurately calculated, it is estimated
and disparaged relative to the cost of a single instruction.

gcc/ChangeLog:

* config/msp430/msp430.c (use_helper_for_const_shift): Add forward
declaration.
Remove unused argument.
(struct msp430_multlib_costs): New struct.
(msp430_is_mem_indirect): New function.
(msp430_costs): Likewise.
(msp430_shift_costs): Likewise.
(msp430_muldiv_costs): Likewise.
(msp430_get_inner_dest_code): Likewise.
(msp430_single_op_cost): Likewise.
(msp430_rtx_costs): Rewrite from scratch.
(msp430_expand_shift): Adjust use_helper_for_const_shift call.

4 years agoMSP430: Implement TARGET_MEMORY_MOVE_COST
Jozef Lawrynowicz [Fri, 13 Nov 2020 15:35:33 +0000 (15:35 +0000)]
MSP430: Implement TARGET_MEMORY_MOVE_COST

The cycle and size cost of a MOV instruction in different addressing
modes can be used to calculate the TARGET_MEMORY_MOVE_COST relative to
TARGET_REGISTER_MOVE_COST.

gcc/ChangeLog:

* config/msp430/msp430.c (struct single_op_cost): New struct.
(struct double_op_cost): Likewise.
(TARGET_REGISTER_MOVE_COST): Don't define but add comment.
(TARGET_MEMORY_MOVE_COST): Define to...
(msp430_memory_move_cost): New function.
(BRANCH_COST): Don't define but add comment.

4 years agoImprove handling of memory operands in ipa-icf 2/4
Jan Hubicka [Fri, 13 Nov 2020 14:58:41 +0000 (15:58 +0100)]
Improve handling of memory operands in ipa-icf 2/4

this patch iplements new class ao_compare that is derived from operand_compare
and adds a method to compare and hash ao_refs.  This is used by ICF to enable
more merging.

Comparsion is done as follows

1) Verify that the memory access will happen at the same address
   and will have same size.

   For constant addresses this is done by comparing ao_ref_base
   and offset/size

   For varable accesses it uses operand_equal_p but with OEP_ADDRESS
   (that does not match TBAA metadata) and then operand_equal_p on
   type size.

2) Compare alignments.  I use get_object_alignment_1 like ipa-icf
   did before revamp to operand_equal_p in gcc 9.
   I noticed that return value is bitodd so added a comment

3) Match MR_DEPENDENCE_CLIQUE

At this point the memory refrences are same except for TBAA information.
We continue by checking

4) ref and base alias sets.  Now if lto streaming is going to happen
   instead of comparing alias sets themselves we compare alias_ptr_types

   (the patch depends on the ao_ref_alias_ptr_tyep and
    ao_ref_base_alias_ptr_type acessors I sent yesterday)

5) See if accesses are view converted.
   If they are we are done since access path is not present

6) Compare the part of access path relevant for TBAA.
   I recall FRE relies on the fact that if base and ref types are same the
   access path is, but I do not thing this is 100% reliable especially with LTO
   alias sets.

   The access path comparsion logic is also useful for modref (for next stage1).
   Tracking the access paths improves quite noticeably disambiguation in C++
   code by being able to distinquish different fields of same type within a
   struct.  I had the comparsion logic in my tree for some time and it seems to
   work quite well.

   During cc1plus build we have some cases where we find mismatch after matching
   the base/ref alias sets.  These are due to failed type merging: access path
   oracle in LTO uses TYPE_MAIN_VARIANTs.

I implemented relatively basic hashing using base and offset.

gcc/ChangeLog:
* ipa-icf-gimple.c: Include tree-ssa-alias-compare.h.
(find_checker::func_checker): Initialize m_tbaa.
(func_checker::hash_operand): Use hash_ao_ref for memory accesses.
(func_checker::compare_operand): Use compare_ao_refs for memory
accesses.
(func_checker::cmopare_gimple_assign): Do not check LHS types
of memory stores.
* ipa-icf-gimple.h (func_checker): Derive from ao_compare;
add m_tbaa.
* ipa-icf.c: Include tree-ssa-alias-compare.h.
(sem_function::equals_private): Update call of
func_checker::func_checker.
* ipa-utils.h (lto_streaming_expected_p): New inline
predicate.
* tree-ssa-alias-compare.h: New file.
* tree-ssa-alias.c: Include tree-ssa-alias-compare.h
and bultins.h
(view_converted_memref_p): New function.
(types_equal_for_same_type_for_tbaa_p): New function.
(ao_ref_alias_ptr_type, ao_ref_base_alias_ptr_type): New functions.
(ao_compare::compare_ao_refs): New member function.
(ao_compare::hash_ao_ref): New function
* tree-ssa-alias.h (ao_ref_base_alias_ptr_type,
ao_ref_alias_ptr_type): Declare.

gcc/testsuite/ChangeLog:
* c-c++-common/Wstringop-overflow-2.c: Disable ICF.
* g++.dg/warn/Warray-bounds-8.C: Disable ICF.

4 years agoDetermine access types in ipa-icf-gimple.c
Jan Hubicka [Fri, 13 Nov 2020 10:41:13 +0000 (11:41 +0100)]
Determine access types in ipa-icf-gimple.c

This patch adds logic to determine access type (normal or memory) for every
operand.  This makes it possible to compare memory accesses more carefully
which will be implemented in a followup patch.

* ipa-icf-gimple.c: Include gimple-walk.h.
(func_checker::compare_ssa_name): Update call of compare_operand.
(func_checker::hash_operand): Fix comment and add variant taking
operand_access_type parameter.
(func_checker::compare_operand): Add operand_access_type parameter.
(func_checker::compare_asm_inputs_outputs): Add
operand_access_type_map parameter; update use of
func_checker::compare_operand.
(func_checker::compare_gimple_call): Update use of
func_checker::compare_operand.
(func_checker::compare_gimple_assign): Likewise.
(func_checker::compare_gimple_cond): Likewise.
(func_checker::compare_gimple_switch): Likewise.
(func_checker::compare_gimple_return): Likewise.
(func_checker::compare_gimple_goto): Likewise.
(func_checker::compare_gimple_asm): Likewise.
(visit_load_store): New static functio.
(func_checker::classify_operands): New member function.
(func_checker::get_operand_access_type): New member function.
* ipa-icf-gimple.h (func_checker::operand_access_type): New enum
(func_checker::operand_access_type_map): New typedef.
(func_checker::compare_operand): Update prototype.
(func_checker::compare_asm_inputs_outputs): Likewise.
(func_checker::cleassify_operands): Declare.
(func_checker::get_operand_access_type): Declare.
(func_checker::hash_operand): New variant with operand_access_type.
* ipa-icf.c (sem_function::hash_stmt): Update uses of hash_operand.
(sem_function::compare_phi_node): Update use of compare_operand.

4 years agoarm: Make use of RTL predicates
Andrea Corallo [Fri, 13 Nov 2020 11:42:04 +0000 (11:42 +0000)]
arm: Make use of RTL predicates

2020-11-13  Andrea Corallo  <andrea.corallo@arm.com>

* config/arm/aarch-common.c (aarch_accumulator_forwarding): Use
RTL predicates where possible.
* config/arm/arm.c (legitimate_pic_operand_p)
(legitimize_pic_address, arm_is_segment_info_known)
(can_avoid_literal_pool_for_label_p)
(thumb1_legitimate_address_p, arm_legitimize_address)
(arm_tls_referenced_p, thumb_legitimate_constant_p)
(REG_OR_SUBREG_REG, thumb1_rtx_costs, thumb1_size_rtx_costs)
(arm_adjust_cost, arm_coproc_mem_operand_wb)
(neon_vector_mem_operand, neon_struct_mem_operand)
(symbol_mentioned_p, label_mentioned_p, )
(load_multiple_sequence, store_multiple_sequence)
(arm_select_cc_mode, arm_reload_in_hi, arm_reload_out_hi)
(mem_ok_for_ldrd_strd, arm_emit_call_insn, output_move_neon)
(arm_attr_length_move_neon, arm_assemble_integer)
(arm_emit_coreregs_64bit_shift, arm_valid_symbolic_address_p)
(extract_base_offset_in_addr, fusion_load_store): Likewise.

4 years agoCleanup range of address calculations.
Andrew MacLeod [Thu, 12 Nov 2020 16:53:52 +0000 (11:53 -0500)]
Cleanup range of address calculations.

Align EVRP and ranger for how ranges of ADDR_EXPR are calculated.

gcc/
* gimple-range.cc: (gimple_ranger::range_of_range_op): Check for
ADDR_EXPR and call range_of_address.
(gimple_ranger::range_of_address): Rename from
range_of_non_trivial_assignment and match vrp_stmt_computes_nonzero.
* gimple-range.h: (range_of_address): Renamed.
* range-op.cc: (pointer_table): Add INTEGER_CST handler.
gcc/testsuite/
* gcc.dg/tree-ssa/pr78655.c: New.

4 years agoloops: Invoke lim after successful loop interchange
Martin Jambor [Fri, 13 Nov 2020 14:35:18 +0000 (15:35 +0100)]
loops: Invoke lim after successful loop interchange

This patch makes the entry point to loop invariant motion public, so
that it can be called after loop interchange when that pass has
swapped loops.  This avoids the non-LTO -Ofast run-time regressions of
410.bwaves and 503.bwaves_r (which are 19% and 15% faster than current
master on an AMD zen2 machine) while not introducing a full LIM pass
into the pass pipeline.

The patch also adds a parameter which allows not to perform any store
motion so that it is not done after an interchange.

gcc/ChangeLog:

2020-11-12  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/94406
* tree-ssa-loop-im.c (tree_ssa_lim): Renamed to
loop_invariant_motion_in_fun, added a parameter to control store
motion.
(pass_lim::execute): Adjust call to tree_ssa_lim, now
loop_invariant_motion_in_fun.
* tree-ssa-loop-manip.h (loop_invariant_motion_in_fun): Declare.
* gimple-loop-interchange.cc (pass_linterchange::execute): Call
loop_invariant_motion_in_fun if any interchange has been done.

4 years agoimprove VN PHI hashing
Richard Biener [Fri, 13 Nov 2020 12:17:01 +0000 (13:17 +0100)]
improve VN PHI hashing

This reduces the number of collisions for PHIs in the VN hashtable
by always hashing the number of predecessors and separately hashing
the block number when we never merge PHIs from different blocks.

This improves collisions seen for the PR69609 testcase dramatically.

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

* tree-ssa-sccvn.c (vn_phi_compute_hash): Always hash the
number of predecessors.  Hash the block number also for
loop header PHIs.
(expressions_equal_p): Short-cut SSA name compares, remove
test for NULL operands.
(vn_phi_eq): Cache number of predecessors, change inlined
test from expressions_equal_p.

4 years agolibphobos: Update libtool version to 2:0:0
Iain Buclaw [Fri, 13 Nov 2020 11:26:01 +0000 (12:26 +0100)]
libphobos: Update libtool version to 2:0:0

This is so that the library is not to conflict with gcc-10.

libphobos/ChangeLog:

* configure: Regenerate.
* configure.ac (libtool_VERSION): Update to 2:0.0.

4 years agod: Explicitly determine which built-in copysign function to call.
Iain Buclaw [Fri, 13 Nov 2020 08:57:57 +0000 (09:57 +0100)]
d: Explicitly determine which built-in copysign function to call.

For some targets, mathfn_built_in returns NULL as copysign is not
implicitly available, causing an ICE.  Now copysign is explicitly
requested when expanding the intrinsic.

gcc/d/ChangeLog:

* intrinsics.cc (expand_intrinsic_copysign): Explicitly determine
which built-in copysign function to call.

4 years agod: Fix ICE in finish_thunk (PR97644)
Iain Buclaw [Thu, 12 Nov 2020 14:37:46 +0000 (15:37 +0100)]
d: Fix ICE in finish_thunk (PR97644)

Because this what the upstream reference compiler did, thunks for the D
front-end were associated with the class definition, so were forced
code-gen even if the target function was extern.  This has now been
changed so there are now only generated if there is a function
definition, fixing the ICE that occurred in PR 97644, which was caused
by calling expand_thunk() early.

gcc/d/ChangeLog:

PR d/97644
* dmd/MERGE: Merge upstream dmd 95044d8e4.
* d-target.cc (TargetCPP::thunkMangle): New function.
* decl.cc (finish_thunk): Don't force expand thunks for external
functions.
(make_thunk): Emit thunks only if the function has a definition.
Generate correct mangling for thunks to C++ classes.

gcc/testsuite/ChangeLog:

* gdc.dg/pr92216.d: Update scan-assember.

4 years agoclang: fix -Wmisleading-indentation warning.
Martin Liska [Fri, 13 Nov 2020 13:04:09 +0000 (14:04 +0100)]
clang: fix -Wmisleading-indentation warning.

gcc/c-family/c-attribs.c:4698:5: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]

gcc/c-family/ChangeLog:

* c-attribs.c (build_attr_access_from_parms): Format properly.

4 years agodoc : Fix build error from r11-4972.
Iain Sandoe [Fri, 13 Nov 2020 11:45:34 +0000 (11:45 +0000)]
doc : Fix build error from r11-4972.

Some tex tools don't allow the @r{} command to be split across
lines.  Fixed by making the change occupy a long line.

gcc/ChangeLog:

* doc/extend.texi: Don't try to line-wrap an @r command.

4 years agotree-optimization/97812 - fix range query in VRP assert discovery
Richard Biener [Fri, 13 Nov 2020 10:31:22 +0000 (11:31 +0100)]
tree-optimization/97812 - fix range query in VRP assert discovery

This makes sure to properly extend the input range before seeing
whether it fits the target.

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

PR tree-optimization/97812
* tree-vrp.c (register_edge_assert_for_2): Extend the range
according to its sign before seeing whether it fits.

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

4 years agoaarch64: Make use of RTL predicates
Andrea Corallo [Tue, 10 Nov 2020 11:23:15 +0000 (11:23 +0000)]
aarch64: Make use of RTL predicates

2020-11-10  Andrea Corallo  <andrea.corallo@arm.com>

* config/aarch64/aarch64.c (tls_symbolic_operand_type)
(aarch64_load_symref_appropriately, aarch64_mov128_immediate)
(aarch64_expand_mov_immediate)
(aarch64_maybe_expand_sve_subreg_move)
(aarch64_tls_referenced_p, aarch64_cannot_force_const_mem)
(aarch64_base_register_rtx_p, aarch64_classify_index)
(aarch64_classify_address, aarch64_symbolic_address_p)
(aarch64_reinterpret_float_as_int, aarch64_float_const_rtx_p)
(aarch64_can_const_movi_rtx_p, aarch64_select_cc_mode)
(aarch64_print_operand, aarch64_label_mentioned_p)
(aarch64_secondary_reload, aarch64_preferred_reload_class)
(aarch64_address_cost, aarch64_tls_symbol_p)
(aarch64_classify_symbol, aarch64_legitimate_pic_operand_p)
(aarch64_legitimate_constant_p)
(aarch64_sve_float_arith_immediate_p)
(aarch64_sve_float_mul_immediate_p, aarch64_mov_operand_p)
(fusion_load_store): Use RTL operands where possible.

4 years agolibstdc++: Add -pthread options to std::future polling test
Jonathan Wakely [Fri, 13 Nov 2020 10:04:33 +0000 (10:04 +0000)]
libstdc++: Add -pthread options to std::future polling test

For linux targets this test doesn't need -lpthread because it only uses
atomics, but for all other targets std::call_once still needs pthreads.
Add the necessary test directives to make that work.

The timings in this test might be too fragile or too target-specific, so
it might need to be adjusted in future, or restricted to only run on
specific targets. For now I've increased the allowed ratio between
wait_for calls before and after the future is made ready, because it was
failing with -O3 -march=native sometimes.

libstdc++-v3/ChangeLog:

* testsuite/30_threads/future/members/poll.cc: Require gthreads
and add -pthread for targets that require it. Relax required
ratio of wait_for calls before/after the future is ready.

4 years agoaarch64: Add backend support for expanding __builtin_memset
Sudakshina Das [Fri, 13 Nov 2020 10:48:27 +0000 (10:48 +0000)]
aarch64: Add backend support for expanding __builtin_memset

This patch implements aarch64 backend expansion for __builtin_memset. Most of
the implementation is based on the expansion of __builtin_memcpy. We change the
values of SET_RATIO and MOVE_RATIO for cases where we do not have to strictly
align and where we can benefit from NEON instructions in the backend.

gcc/ChangeLog:

* config/aarch64/aarch64-protos.h (aarch64_expand_setmem): New
declaration.
* config/aarch64/aarch64.c (aarch64_gen_store_pair): Add case for
E_V16QImode.
(aarch64_set_one_block_and_progress_pointer): New helper for
aarch64_expand_setmem.
(aarch64_expand_setmem): Define the expansion for memset.
* config/aarch64/aarch64.h (CLEAR_RATIO): Tweak to favor
aarch64_expand_setmem when allowed and profitable.
(SET_RATIO): Likewise.
* config/aarch64/aarch64.md: Define pattern for setmemdi.

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/pr90883.C: Remove xfail for aarch64.
* gcc.dg/tree-prof/stringop-2.c: Add xfail for aarch64.
* gcc.target/aarch64/memset-corner-cases.c: New test.
* gcc.target/aarch64/memset-q-reg.c: New test.

4 years agoC-Family, Objective-C : Implement Objective-C nullability Part 1[PR90707].
Iain Sandoe [Sun, 25 Oct 2020 19:33:07 +0000 (19:33 +0000)]
C-Family, Objective-C : Implement Objective-C nullability Part 1[PR90707].

This part of the implementation covers property nullability attributes
and includes the changes to common code. Follow-on changes will be needed
to cover Objective-C method definitions, but those are expected to be
local to the Objective-C front end.

The basis of the implementation is to translate the Objective-C-specific
keywords into an attribute (objc_nullability) which has the required
states to carry the attribute markup.

We introduce the keywords, and these are parsed and validated in the same
manner as other property attributes.  The resulting value is attached to
the property as an objc_nullability attribute.

gcc/c-family/ChangeLog:

PR objc/90707
* c-common.c (c_common_reswords): null_unspecified, nullable,
nonnull, null_resettable: New keywords.
* c-common.h (enum rid): RID_NULL_UNSPECIFIED, RID_NULLABLE,
RID_NONNULL, RID_NULL_RESETTABLE: New.
(OBJC_IS_PATTR_KEYWORD): Include nullability keywords in the
ranges accepted for property attributes.
* c-attribs.c (handle_objc_nullability_attribute): New.
* c-objc.h (enum objc_property_attribute_group): Add
OBJC_PROPATTR_GROUP_NULLABLE.
(enum objc_property_attribute_kind):Add
OBJC_PROPERTY_ATTR_NULL_UNSPECIFIED, OBJC_PROPERTY_ATTR_NULLABLE,
OBJC_PROPERTY_ATTR_NONNULL, OBJC_PROPERTY_ATTR_NULL_RESETTABLE.

gcc/objc/ChangeLog:

PR objc/90707
* objc-act.c (objc_prop_attr_kind_for_rid): Handle nullability.
(objc_add_property_declaration): Handle nullability attributes.
Check that these are applicable to the property type.
* objc-act.h (enum objc_property_nullability): New.

gcc/testsuite/ChangeLog:

PR objc/90707
* obj-c++.dg/property/at-property-4.mm: Add basic nullability
tests.
* objc.dg/property/at-property-4.m: Likewise.
* obj-c++.dg/attributes/nullability-00.mm: New test.
* obj-c++.dg/property/nullability-00.mm: New test.
* objc.dg/attributes/nullability-00.m: New test.
* objc.dg/property/nullability-00.m: New test.

gcc/ChangeLog:

PR objc/90707
* doc/extend.texi: Document the objc_nullability attribute.

4 years agoObjective-C [3/3] : Implement Wobjc-root-class [PR77404].
Iain Sandoe [Sun, 25 Oct 2020 09:54:21 +0000 (09:54 +0000)]
Objective-C [3/3] : Implement Wobjc-root-class [PR77404].

Add Wno-objc-root-class where needed to the objective-c++
tests.

gcc/testsuite/ChangeLog:

PR objc/77404
* obj-c++.dg/attributes/class-attribute-1.mm:
Add Wno-objc-root-class.
* obj-c++.dg/attributes/class-attribute-2.mm: Likewise.
* obj-c++.dg/attributes/class-attribute-3.mm: Likewise.
* obj-c++.dg/attributes/method-deprecated-1.mm: Likewise.
* obj-c++.dg/attributes/method-deprecated-2.mm: Likewise.
* obj-c++.dg/attributes/method-deprecated-3.mm: Likewise.
* obj-c++.dg/attributes/method-format-1.mm: Likewise.
* obj-c++.dg/attributes/method-nonnull-1.mm: Likewise.
* obj-c++.dg/attributes/method-noreturn-1.mm: Likewise.
* obj-c++.dg/attributes/method-sentinel-1.mm: Likewise.
* obj-c++.dg/attributes/nsobject-01.mm: Likewise.
* obj-c++.dg/attributes/parameter-attribute-1.mm: Likewise.
* obj-c++.dg/attributes/parameter-attribute-2.mm: Likewise.
* obj-c++.dg/attributes/proto-attribute-1.mm: Likewise.
* obj-c++.dg/attributes/proto-attribute-3.mm: Likewise.
* obj-c++.dg/attributes/proto-attribute-4.mm: Likewise.
* obj-c++.dg/attributes/unused-parameter-1.mm: Likewise.
* obj-c++.dg/bad-receiver-type.mm: Likewise.
* obj-c++.dg/bitfield-3.mm: Likewise.
* obj-c++.dg/bitfield-5.mm: Likewise.
* obj-c++.dg/class-extension-1.mm: Likewise.
* obj-c++.dg/class-extension-2.mm: Likewise.
* obj-c++.dg/class-extension-3.mm: Likewise.
* obj-c++.dg/class-extension-4.mm: Likewise.
* obj-c++.dg/class-protocol-1.mm: Likewise.
* obj-c++.dg/comp-types-1.mm: Likewise.
* obj-c++.dg/comp-types-10.mm: Likewise.
* obj-c++.dg/comp-types-2.mm: Likewise.
* obj-c++.dg/comp-types-3.mm: Likewise.
* obj-c++.dg/comp-types-5.mm: Likewise.
* obj-c++.dg/comp-types-6.mm: Likewise.
* obj-c++.dg/comp-types-7.mm: Likewise.
* obj-c++.dg/comp-types-8.mm: Likewise.
* obj-c++.dg/demangle-2.mm: Likewise.
* obj-c++.dg/demangle-3.mm: Likewise.
* obj-c++.dg/duplicate-class-1.mm: Likewise.
* obj-c++.dg/encode-1-next.mm: Likewise.
* obj-c++.dg/encode-1.mm: Likewise.
* obj-c++.dg/enhanced-proto-2.mm: Likewise.
* obj-c++.dg/exceptions-1.mm: Likewise.
* obj-c++.dg/exceptions-3.mm: Likewise.
* obj-c++.dg/exceptions-4.mm: Likewise.
* obj-c++.dg/exceptions-5.mm: Likewise.
* obj-c++.dg/extern-c-1.mm: Likewise.
* obj-c++.dg/fobjc-std-1.mm: Likewise.
* obj-c++.dg/gnu-api-2-class-meta.mm: Likewise.
* obj-c++.dg/gnu-api-2-class.mm: Likewise.
* obj-c++.dg/gnu-api-2-ivar.mm: Likewise.
* obj-c++.dg/gnu-api-2-method.mm: Likewise.
* obj-c++.dg/gnu-api-2-objc.mm: Likewise.
* obj-c++.dg/gnu-api-2-objc_msg_lookup.mm: Likewise.
* obj-c++.dg/gnu-api-2-object.mm: Likewise.
* obj-c++.dg/gnu-api-2-property.mm: Likewise.
* obj-c++.dg/gnu-api-2-protocol.mm: Likewise.
* obj-c++.dg/gnu-api-2-resolve-method.mm: Likewise.
* obj-c++.dg/gnu-api-2-sel.mm: Likewise.
* obj-c++.dg/invalid-method-2.mm: Likewise.
* obj-c++.dg/ivar-invalid-type-1.mm: Likewise.
* obj-c++.dg/ivar-problem-1.mm: Likewise.
* obj-c++.dg/lto/lto.exp: Likewise.
* obj-c++.dg/lto/trivial-1_0.mm: Likewise.
* obj-c++.dg/method-1.mm: Likewise.
* obj-c++.dg/method-12.mm: Likewise.
* obj-c++.dg/method-18.mm: Likewise.
* obj-c++.dg/method-19.mm: Likewise.
* obj-c++.dg/method-20.mm: Likewise.
* obj-c++.dg/method-3.mm: Likewise.
* obj-c++.dg/method-4.mm: Likewise.
* obj-c++.dg/method-5.mm: Likewise.
* obj-c++.dg/method-8.mm: Likewise.
* obj-c++.dg/method-9.mm: Likewise.
* obj-c++.dg/method-namespace-1.mm: Likewise.
* obj-c++.dg/plugin/diagnostic-test-expressions-1.mm:
Likewise.
* obj-c++.dg/pr23709.mm: Likewise.
* obj-c++.dg/pragma-2.mm: Likewise.
* obj-c++.dg/private-1.mm: Likewise.
* obj-c++.dg/private-2.mm: Likewise.
* obj-c++.dg/property/property.exp: Likewise.
* obj-c++.dg/proto-lossage-1.mm: Likewise.
* obj-c++.dg/proto-lossage-5.mm: Likewise.
* obj-c++.dg/proto-qual-1.mm: Likewise.
* obj-c++.dg/protocol-inheritance-1.mm: Likewise.
* obj-c++.dg/protocol-inheritance-2.mm: Likewise.
* obj-c++.dg/protocol-optional-1.mm: Likewise.
* obj-c++.dg/selector-1.mm: Likewise.
* obj-c++.dg/selector-2.mm: Likewise.
* obj-c++.dg/selector-3.mm: Likewise.
* obj-c++.dg/selector-4.mm: Likewise.
* obj-c++.dg/strings/strings.exp: Likewise.
* obj-c++.dg/stubify-1.mm: Likewise.
* obj-c++.dg/stubify-2.mm: Likewise.
* obj-c++.dg/super-dealloc-1.mm: Likewise.
* obj-c++.dg/super-dealloc-2.mm: Likewise.
* obj-c++.dg/sync-3.mm: Likewise.
* obj-c++.dg/syntax-error-2.mm: Likewise.
* obj-c++.dg/syntax-error-4.mm: Likewise.
* obj-c++.dg/syntax-error-7.mm: Likewise.
* obj-c++.dg/syntax-error-9.mm: Likewise.
* obj-c++.dg/template-4.mm: Likewise.
* obj-c++.dg/template-7.mm: Likewise.
* obj-c++.dg/template-8.mm: Likewise.
* obj-c++.dg/threedotthree-abi-1.mm: Likewise.
* obj-c++.dg/torture/dg-torture.exp: Likewise.
* obj-c++.dg/torture/strings/strings.exp: Likewise.
* obj-c++.dg/try-catch-12.mm: Likewise.
* obj-c++.dg/try-catch-13.mm: Likewise.

4 years agoObjective-C [2/3] : Implement Wobjc-root-class [PR77404].
Iain Sandoe [Thu, 12 Nov 2020 13:11:11 +0000 (13:11 +0000)]
Objective-C [2/3] : Implement Wobjc-root-class [PR77404].

Add "Wno-objc-root-class" to tests in the Objective-C suite where
needed.

gcc/testsuite/ChangeLog:

PR objc/77404
* objc.dg/anon-1.m: Add Wno-objc-root-class.
* objc.dg/attributes/class-attribute-1.m: Likewise.
* objc.dg/attributes/class-attribute-2.m: Likewise.
* objc.dg/attributes/class-attribute-3.m: Likewise.
* objc.dg/attributes/method-deprecated-1.m: Likewise.
* objc.dg/attributes/method-deprecated-2.m: Likewise.
* objc.dg/attributes/method-deprecated-3.m: Likewise.
* objc.dg/attributes/method-format-1.m: Likewise.
* objc.dg/attributes/method-nonnull-1.m: Likewise.
* objc.dg/attributes/method-noreturn-1.m: Likewise.
* objc.dg/attributes/method-sentinel-1.m: Likewise.
* objc.dg/attributes/nsobject-01.m: Likewise.
* objc.dg/attributes/objc-exception-1.m: Likewise.
* objc.dg/attributes/parameter-attribute-1.m: Likewise.
* objc.dg/attributes/parameter-attribute-2.m: Likewise.
* objc.dg/attributes/proto-attribute-1.m: Likewise.
* objc.dg/attributes/proto-attribute-2.m: Likewise.
* objc.dg/attributes/proto-attribute-3.m: Likewise.
* objc.dg/attributes/proto-attribute-4.m: Likewise.
* objc.dg/bitfield-2.m: Likewise.
* objc.dg/break-in-ifstmt.m: Likewise.
* objc.dg/class-1.m: Likewise.
* objc.dg/class-extension-1.m: Likewise.
* objc.dg/class-extension-2.m: Likewise.
* objc.dg/class-extension-3.m: Likewise.
* objc.dg/class-extension-4.m: Likewise.
* objc.dg/class-protocol-1.m: Likewise.
* objc.dg/comp-types-7.m: Likewise.
* objc.dg/demangle-1.m: Likewise.
* objc.dg/duplicate-class-1.m: Likewise.
* objc.dg/encode-6-next.m: Likewise.
* objc.dg/encode-6.m: Likewise.
* objc.dg/enhanced-proto-2.m: Likewise.
* objc.dg/exceptions-1.m: Likewise.
* objc.dg/exceptions-3.m: Likewise.
* objc.dg/exceptions-4.m: Likewise.
* objc.dg/exceptions-5.m: Likewise.
* objc.dg/fobjc-std-1.m: Likewise.
* objc.dg/foreach-2.m: Likewise.
* objc.dg/foreach-4.m: Likewise.
* objc.dg/foreach-5.m: Likewise.
* objc.dg/fsyntax-only.m: Likewise.
* objc.dg/gnu-api-2-class-meta.m: Likewise.
* objc.dg/gnu-api-2-class.m: Likewise.
* objc.dg/gnu-api-2-ivar.m: Likewise.
* objc.dg/gnu-api-2-method.m: Likewise.
* objc.dg/gnu-api-2-objc.m: Likewise.
* objc.dg/gnu-api-2-objc_msg_lookup.m: Likewise.
* objc.dg/gnu-api-2-object.m: Likewise.
* objc.dg/gnu-api-2-property.m: Likewise.
* objc.dg/gnu-api-2-protocol.m: Likewise.
* objc.dg/gnu-api-2-resolve-method.m: Likewise.
* objc.dg/gnu-api-2-sel.m: Likewise.
* objc.dg/incomplete-type-1.m: Likewise.
* objc.dg/instancetype-0.m: Likewise.
* objc.dg/invalid-method-2.m: Likewise.
* objc.dg/ivar-invalid-type-1.m: Likewise.
* objc.dg/ivar-problem-1.m: Likewise.
* objc.dg/ivar-scope-1.m: Likewise.
* objc.dg/ivar-scope-2.m: Likewise.
* objc.dg/ivar-scope-4.m: Likewise.
* objc.dg/ivar-visibility-1.m: Likewise.
* objc.dg/ivar-visibility-2.m: Likewise.
* objc.dg/ivar-visibility-3.m: Likewise.
* objc.dg/ivar-visibility-4.m: Likewise.
* objc.dg/local-decl-1.m: Likewise.
* objc.dg/lto/lto.exp: Likewise.
* objc.dg/lto/trivial-1_0.m: Likewise.
* objc.dg/method-1.m: Likewise.
* objc.dg/method-12.m: Likewise.
* objc.dg/method-13.m: Likewise.
* objc.dg/method-14.m: Likewise.
* objc.dg/missing-proto-3.m: Likewise.
* objc.dg/next-runtime-1.m: Likewise.
* objc.dg/objc-foreach-1.m: Likewise.
* objc.dg/objc-foreach-2.m: Likewise.
* objc.dg/objc-foreach-3.m: Likewise.
* objc.dg/objc-nofilename-1.m: Likewise.
* objc.dg/param-1.m: Likewise.
* objc.dg/pch/pch.exp: Likewise.
* objc.dg/plugin/diagnostic-test-expressions-1.m: Likewise.
* objc.dg/pr23709.m: Likewise.
* objc.dg/private-1.m: Likewise.
* objc.dg/private-2.m: Likewise.
* objc.dg/property/property.exp: Likewise.
* objc.dg/proto-hier-1.m: Likewise.
* objc.dg/proto-hier-2.m: Likewise.
* objc.dg/proto-lossage-1.m: Likewise.
* objc.dg/proto-lossage-5.m: Likewise.
* objc.dg/proto-qual-1.m: Likewise.
* objc.dg/protocol-inheritance-1.m: Likewise.
* objc.dg/protocol-inheritance-2.m: Likewise.
* objc.dg/protocol-optional-1.m: Likewise.
* objc.dg/selector-1.m: Likewise.
* objc.dg/selector-2.m: Likewise.
* objc.dg/selector-3.m: Likewise.
* objc.dg/selector-4.m: Likewise.
* objc.dg/shadow-1.m: Likewise.
* objc.dg/shadow-2.m: Likewise.
* objc.dg/special/load-category-1.m: Likewise.
* objc.dg/special/load-category-2.m: Likewise.
* objc.dg/special/load-category-3.m: Likewise.
* objc.dg/special/special.exp: Likewise.
* objc.dg/special/unclaimed-category-1.h: Likewise.
* objc.dg/special/unclaimed-category-1.m: Likewise.
* objc.dg/stabs-1.m: Likewise.
* objc.dg/strings/strings.exp: Likewise.
* objc.dg/stubify-1.m: Likewise.
* objc.dg/stubify-2.m: Likewise.
* objc.dg/super-class-2.m: Likewise.
* objc.dg/super-dealloc-1.m: Likewise.
* objc.dg/super-dealloc-2.m: Likewise.
* objc.dg/sync-3.m: Likewise.
* objc.dg/threedotthree-abi-1.m: Likewise.
* objc.dg/torture/dg-torture.exp: Likewise.
* objc.dg/torture/strings/strings.exp: Likewise.
* objc.dg/try-catch-11.m: Likewise.
* objc.dg/try-catch-12.m: Likewise.
* objc.dg/type-size-2.m: Likewise.
* objc.dg/type-size-3.m: Likewise.
* objc.dg/type-size-4.m: Likewise.
* objc.dg/type-size-5.m: Likewise.
* objc.dg/undeclared-selector.m: Likewise.
* objc.dg/volatile-1.m: Likewise.

4 years agoC-family, Objective-C [1/3] : Implement Wobjc-root-class [PR77404].
Iain Sandoe [Sun, 25 Oct 2020 07:49:16 +0000 (07:49 +0000)]
C-family, Objective-C [1/3] : Implement Wobjc-root-class [PR77404].

This warning catches the case that the user has left the
superclass specification from a class interface.  Root
classes are, of course, permitted and an attribute is added
to mark these so that the diagnostic is suppressed.

The warning and attribute spellings have been kept in sync
with the language reference implementation (clang).

The diagnostic location information present in the objective-c
interface and class definitions is relatively poor.  This patch
adds a location for the class name to the interface and makes use
of it in existing warnings.

Part 1 is the changes to code and added tests.

Many entries in the testsuite make use of root classes so
there are a large number of mechanical changes there adding
"-Wno-objc-root-class" to the options.

The test changes are parts 2 (objective-c) and 3 (objective-c++)
in the patch series.

gcc/c-family/ChangeLog:

PR objc/77404
* c-attribs.c (handle_objc_root_class_attribute): New
* c-objc.h (objc_start_class_interface): Add a location
value for the position of the class name.
* c.opt: Add Wobjc-root-class.
* stub-objc.c (objc_start_class_interface): Add a location
value for the position of the class name.

gcc/c/ChangeLog:

PR objc/77404
* c-parser.c (c_parser_objc_class_definition): Pass the
location of the class name to the interface declaration.

gcc/cp/ChangeLog:

PR objc/77404
* parser.c (cp_parser_objc_class_interface): Pass the
location of the class name to the interface declaration.

gcc/objc/ChangeLog:

PR objc/77404
* objc-act.c (objc_start_class_interface): Accept the location
of the class name, use it in existing diagnostic.
(start_class): Accept obj_root_class type attributes.  Warn when
the interface for an implementation does not contain a super
class (unless the diagnostic is suppressed by the the command
line flag or the objc_root_class type attribute).

gcc/testsuite/ChangeLog:

PR objc/77404
* objc.dg/attributes/root-class-01.m: New test.
* objc.dg/root-class-00.m: New test.
* obj-c++.dg/attributes/root-class-01.mm: New test.
* obj-c++.dg/root-class-00.mm: New test.

gcc/ChangeLog:

PR objc/77404
* doc/extend.texi: Document the objc_root_class attribute.
* doc/invoke.texi: Document -Wobjc-root-class.

4 years agoremove almost all users of gimple_expr_code
Richard Biener [Fri, 13 Nov 2020 10:33:22 +0000 (11:33 +0100)]
remove almost all users of gimple_expr_code

This replaces the old-school gimple_expr_code with more selective
functions throughout the compiler, in all cases making the code
shorter or more clear.

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

* cfgexpand.c (gimple_assign_rhs_to_tree): Use
gimple_assign_rhs_class.
(expand_gimple_stmt_1): Likewise.
* gimplify-me.c (gimple_regimplify_operands): Use
gimple_assign_single_p.
* ipa-icf-gimple.c (func_checker::compare_gimple_assign):
Remove redundant compare.
(func_checker::compare_gimple_cond): Use gimple_cond_code.
* tree-ssa-tail-merge.c (gimple_equal_p): Likewise.
* predict.c (predict_loops): Use gimple_assign_rhs_code.

4 years agoInline delegators in vrp_folder.
Aldy Hernandez [Wed, 11 Nov 2020 20:09:16 +0000 (21:09 +0100)]
Inline delegators in vrp_folder.

gcc/ChangeLog:

* tree-vrp.c (class vrp_folder): Make visit_stmt, visit_phi,
and m_vr_values private.
(vrp_folder::vrp_evaluate_conditional): Remove.
(vrp_folder::vrp_simplify_stmt_using_ranges): Remove.
(vrp_folder::fold_predicate_in): Inline
vrp_evaluate_conditional and vrp_simplify_stmt_using_ranges.
(vrp_folder::fold_stmt): Same.

4 years agoMove vr_values out of vrp_prop into execute_vrp so it can be shared.
Aldy Hernandez [Wed, 11 Nov 2020 20:04:58 +0000 (21:04 +0100)]
Move vr_values out of vrp_prop into execute_vrp so it can be shared.

vr_values is being shared among the propagator and the folder and
passed around.  I've pulled it out from the propagator so it can be
passed around to each, instead of being publicly accessible from the
propagator.

gcc/ChangeLog:

* tree-vrp.c (class vrp_prop): Rename vr_values to m_vr_values.
(vrp_prop::vrp_prop): New.
(vrp_prop::initialize): Rename vr_values to m_vr_values.
(vrp_prop::visit_stmt): Same.
(vrp_prop::visit_phi): Same.
(vrp_prop::finalize): Same.
(execute_vrp): Instantiate vrp_vr_values and pass it to folder
and propagator.

4 years agoMove vrp_prop before vrp_folder.
Aldy Hernandez [Wed, 11 Nov 2020 19:48:34 +0000 (20:48 +0100)]
Move vrp_prop before vrp_folder.

gcc/ChangeLog:

* tree-vrp.c (class vrp_prop): Move entire class...
(class vrp_folder): ...before here.

4 years agoRefactor VRP threading code into vrp_jump_threader class.
Aldy Hernandez [Wed, 11 Nov 2020 19:10:42 +0000 (20:10 +0100)]
Refactor VRP threading code into vrp_jump_threader class.

gcc/ChangeLog:

* tree-vrp.c (identify_jump_threads): Refactor to..
(vrp_jump_threader::vrp_jump_threader): ...here
(vrp_jump_threader::~vrp_jump_threader): ...and here.
(vrp_jump_threader::after_dom_children): Rename vr_values to
m_vr_values.
(execute_vrp): Use vrp_jump_threader.

4 years agoGroup tree-vrp.c by functionality.
Aldy Hernandez [Wed, 11 Nov 2020 17:30:01 +0000 (18:30 +0100)]
Group tree-vrp.c by functionality.

Earlier in this cycle there was some work by Giuliano Belinassi and
myself to refactor tree-vrp.c.  A lot of functions and globals were
moved into independent classes, but the haphazard layout remained.
Assertion methods were indispersed with the propagation code, and with
the jump threading code, etc etc.

This series of patches moves things around so that common
functionality is geographically close.  There is no change in
behavior.

I know this is all slated to go in the next release, but finding
things in the current code base, even if just to compare with the
ranger, is difficult.

Since I keep getting bit by aarch64 regressions, I've tested the whole
set of patches on aarch64, as well as individually on x86-64 Linux.

gcc/ChangeLog:

* tree-vrp.c (struct assert_locus): Move.
(class vrp_insert): Rename to vrp_asserts.
(vrp_insert::build_assert_expr_for): Move to vrp_asserts.
(fp_predicate): Same.
(vrp_insert::dump): Same.
(vrp_insert::register_new_assert_for): Same.
(extract_code_and_val_from_cond_with_ops): Move.
(vrp_insert::finish_register_edge_assert_for): Move to vrp_asserts.
(maybe_set_nonzero_bits): Move.
(vrp_insert::find_conditional_asserts): Move to vrp_asserts.
(stmt_interesting_for_vrp): Move.
(struct case_info): Move.
(compare_case_labels): Move.
(lhs_of_dominating_assert): Move.
(find_case_label_index): Move.
(find_case_label_range): Move.
(class vrp_asserts): New.
(vrp_asserts::build_assert_expr_for): Rename from vrp_insert.
(vrp_asserts::dump): Same.
(vrp_asserts::register_new_assert_for): Same.
(vrp_asserts::finish_register_edge_assert_for): Same.
(vrp_asserts::find_conditional_asserts): Same.
(vrp_asserts::compare_case_labels): Same.
(vrp_asserts::find_switch_asserts): Same.
(vrp_asserts::find_assert_locations_in_bb): Same.
(vrp_asserts::find_assert_locations): Same.
(vrp_asserts::process_assert_insertions_for): Same.
(vrp_asserts::compare_assert_loc): Same.
(vrp_asserts::process_assert_insertions): Same.
(vrp_asserts::insert_range_assertions): Same.
(vrp_asserts::all_imm_uses_in_stmt_or_feed_cond): Same.
(vrp_asserts::remove_range_assertions): Same.
(class vrp_prop): Move.
(all_imm_uses_in_stmt_or_feed_cond): Move.
(vrp_prop::vrp_initialize): Move.
(class vrp_folder): Move.
(vrp_folder::fold_predicate_in): Move.
(vrp_folder::fold_stmt): Move.
(vrp_prop::initialize): Move.
(vrp_prop::visit_stmt): Move.
(enum ssa_prop_result): Move.
(vrp_prop::visit_phi): Move.
(vrp_prop::finalize): Move.
(class vrp_dom_walker): Rename to...
(class vrp_jump_threader): ...this.
(vrp_jump_threader::before_dom_children): Rename from
vrp_dom_walker.
(simplify_stmt_for_jump_threading): Rename to...
(vrp_jump_threader::simplify_stmt): ...here.
(vrp_jump_threader::after_dom_children): Same.
(identify_jump_threads): Move.
(vrp_prop::vrp_finalize): Move array bounds setup code to...
(execute_vrp): ...here.

4 years agoMAINTAINERS: add myself for write after approval
Haochen Gui [Fri, 13 Nov 2020 03:01:12 +0000 (11:01 +0800)]
MAINTAINERS: add myself for write after approval

ChangeLog:

2020-11-13  Haochen Gui  <guihaoc@gcc.gnu.org>

* MAINTAINERS (Write After Approval): add myself