Commit Graph

186260 Commits

Author SHA1 Message Date
Indu Bhagat b7e215a8ee CTF/BTF debug formats
This commit introduces support for generating CTF debugging
information and BTF debugging information from GCC.

2021-06-28  Indu Bhagat  <indu.bhagat@oracle.com>
	    David Faust  <david.faust@oracle.com>
	    Jose E. Marchesi  <jose.marchesi@oracle.com>
	    Weimin Pan  <weimin.pan@oracle.com>

gcc/

	* Makefile.in: Add ctfc.*, ctfout.c and btfout.c files to
	GTFILES.  Add new object files.
	* common.opt: Add CTF and BTF debug info options.
	* btfout.c: New file.
	* ctfc.c: Likewise.
	* ctfc.h: Likewise.
	* ctfout.c: Likewise.
	* dwarf2ctf.c: Likewise.
	* dwarf2ctf.h: Likewise.
	* dwarf2cfi.c (dwarf2out_do_frame): Acknowledge CTF_DEBUG and
	BTF_DEBUG.
	* dwarf2out.c (dwarf2out_source_line): Likewise.
	(dwarf2out_finish): Skip emitting DWARF if CTF or BTF are to
	be generated.
	(debug_format_do_cu): New function.
	(dwarf2out_early_finish): Traverse DIEs and emit CTF/BTF for
	them if	requested.
	Include dwarf2ctf.c.
	* final.c (dwarf2_debug_info_emitted_p): Acknowledge DWARF-based debug
	formats.
	* flag-types.h (enum debug_info_type): Add CTF_DEBUG and BTF_DEBUG.
	(CTF_DEBUG): New bitmask.
	(BTF_DEBUG): Likewise.
	(enum ctf_debug_info_levels): New enum.
	* gengtype.c (open_base_files): Handle ctfc.h.
	(main): Handle uint32_t type.
	* flags.h (btf_debuginfo_p): New definition.
	(dwarf_based_debuginfo_p): Likewise.
	* opts.c (debug_type_names): Add entries for CTF and BTF.
	(btf_debuginfo_p): New function.
	(dwarf_based_debuginfo_p): Likewise.
	(common_handle_option): Handle -gctfN and -gbtf options.
	(set_debug_level): Set CTF_DEBUG, BTF_DEBUG whenever appropriate.
	* toplev.c (process_options): Inform the user and ignore -gctfLEVEL if
	frontend is not C.

include/

	* ctf.h: New file.
	* btf.h: Likewise.

libiberty/

	* simple-object.c (handle_lto_debug_sections): Copy over .ctf
	sections.
2021-06-28 18:47:20 +02:00
Indu Bhagat 532617d636 dejagnu: modularize gcc-dg-debug-runtest a bit
Move some functionality into a procedure of its own. This is only so that when
the patch for ctf comes along, the gcc-dg-debug-runtest procedure looks bit
more uniform.

gcc/testsuite/ChangeLog:

	* lib/gcc-dg.exp (gcc-dg-target-supports-debug-format): New procedure.
2021-06-28 18:47:20 +02:00
Indu Bhagat 5783a0cc78 dwarf: externalize some DWARF internals for needs of CTF/BTF
This patch externalizes some internal DIE structures and their attributes
for the use of DWARF-based debug formats like CTF and BTF.

The following functions which were previously defined as static in
dwarf2out.c are now non-static, and extern prototypes for them have
been added to dwarf2out.h:

- get_AT
- AT_int
- AT_class
- AT_loc
- get_AT_ref
- get_AT_string
- get_AT_class
- AT_unsigned
- get_AT_unsigned
- get_AT_flag
- add_name_attribute
- new_die_raw
- base_type_die
- lookup_decl_die
- get_AT_file

Note how this patch doens't change the names of these functions to
avoid a massive renaming in dwarf2out.c, but in the future we probably
want these functions to sport a dw_* prefix.

Also, some type definitions have been moved from dwarf2out.c to
dwarf2out.h:

- dw_attr_node
- struct dwarf_file_data

Finally, three new accessor functions have been added to dwarf2out.c
with prototypes in dwarf2out.h:

- dw_get_die_child
- dw_get_die_sib
- dw_get_die_tag

2021-06-28  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* dwarf2out.c (AT_class): Function is no longer static.
	(AT_int): Likewise.
	(AT_unsigned): Likewise.
	(AT_loc): Likewise.
	(get_AT): Likewise.
	(get_AT_string): Likewise.
	(get_AT_flag): Likewise.
	(get_AT_unsigned): Likewise.
	(get_AT_ref): Likewise.
	(new_die_raw): Likewise.
	(lookup_decl_die): Likewise.
	(base_type_die): Likewise.
	(add_name_attribute): Likewise.
	(add_AT_int): Likewise.
	(add_AT_unsigned): Likewise.
	(add_AT_loc): Likewise.
	(dw_get_die_tag): New function.
	(dw_get_die_child): Likewise.
	(dw_get_die_sib): Likewise.
	(struct dwarf_file_data): Move from here to dwarf2out.h
	(struct dw_attr_struct): Likewise.
	* dwarf2out.h: Analogous changes.
2021-06-28 18:47:20 +02:00
Martin Jambor 2902991a6b
ipa-sra: Introduce a mini-DCE to tree-inline.c (PR 93385)
I was asked by Richi to split my fix for PR 93385 for easier review
into IPA-SRA materialization refactoring and the actual DCE addition.
This is the second part that actually contains the DCE of statements
that IPA-SRA should not leave behind because they can have problematic
side effects, even if they are useless, so that we do not depend on
tree-dce to remove them for correctness.

The patch fixes the problem by doing a def-use walk when materializing
clones, marking which statements should not be copied and which
SSA_NAMEs do not need to be computed because eventually they would be
DCEd.  We do this on the original function body and tree-inline simply
does not copy statements which are "dead."

The only complication is removing dead argument calls because that
needs to be communicated to callee redirection code using the
infrastructure introduced by the previous patch.

I added all testcases of the original patch to this one, although some
probably test behavior introduced in the previous patch.

gcc/ChangeLog:

2021-05-12  Martin Jambor  <mjambor@suse.cz>

	PR ipa/93385
	* ipa-param-manipulation.h (class ipa_param_body_adjustments): New
	members m_dead_stmts and m_dead_ssas.
	* ipa-param-manipulation.c
	(ipa_param_body_adjustments::mark_dead_statements): New function.
	(ipa_param_body_adjustments::common_initialization): Call it on
	all removed but not split parameters.
	(ipa_param_body_adjustments::ipa_param_body_adjustments): Initialize
	new mwmbers.
	(ipa_param_body_adjustments::modify_call_stmt): Remove arguments that
	are dead.
	* tree-inline.c (remap_gimple_stmt): Do not copy dead statements, reset
	dead debug statements.
	(copy_phis_for_bb): Do not copy dead PHI nodes.

gcc/testsuite/ChangeLog:

2021-03-22  Martin Jambor  <mjambor@suse.cz>

	PR ipa/93385
	* gcc.dg/ipa/pr93385.c: New test.
	* gcc.dg/ipa/ipa-sra-23.c: Likewise.
	* gcc.dg/ipa/ipa-sra-24.c: Likewise.
	* g++.dg/ipa/ipa-sra-4.C: Likewise.
2021-06-28 18:24:54 +02:00
Martin Jambor 87467f45e8
ipa-sra: Restructure how cloning and call redirection communicate (PR 93385)
I was asked by Richi to split my fix for PR 93385 for easier review
into IPA-SRA materialization refactoring and the actual DCE addition.
Fortunately it was mostly natural except for a temporary weird
condition in ipa_param_body_adjustments::modify_call_stmt.
Additionally.  In addition to the patch I posted previously, this one
also deallocated the newly added summary in toplev::finalize and fixes
a mistakenly uninitialized field.

This is the first part which basically replaces performed_splits in
clone_info and the code which generates it, keeps it up-to-date and
consumes it with new edge summaries which are much nicer.  It simply
contains 1) a mapping from the original argument indices to the actual
indices in the call statement as it is now, 2) information needed to
identify arguments representing pass-through IPA-SRA splits with which
have been added to the call arguments in place of an original
argument/reference and 3) a delta to the index where va_args may start
- so basically directly all the information that the consumer of
performed_splits had to compute and we also do not need the weird
dummy declarations.

The main disadvantage is that the information has to be created (and
kept up-to-date) for all call graph edges associated with the given
statement from all clones (including inline clones) of the clone where
splitting or removal happened first.  But all of this happens during
clone materialization so the only effect on WPA memory consumption is
the removal of a pointer from clone_info.

The statement modification code also has to know the statement from
the original function in order to be able to locate the edge summaries
which at this point are still keyed to these.  However, the code is
already quite heavily dependant on how things are structured in
tree-inline.c and in order to fix bugs like these it probably has to
be.

The subsequent patch needs this new information to be able to remove
arguments from calls during materialization and communicate this
information to the call redirection.

gcc/ChangeLog:

2021-05-17  Martin Jambor  <mjambor@suse.cz>

	PR ipa/93385
	* symtab-clones.h (clone_info): Removed member param_adjustments.
	* ipa-param-manipulation.h: Adjust initial comment to reflect how we
	deal with pass-through splits now.
	(ipa_param_performed_split): Removed.
	(ipa_param_adjustments::modify_call): Adjusted parameters.
	(class ipa_param_body_adjustments): Adjusted parameters of
	register_replacement, modify_gimple_stmt and modify_call_stmt.
	(ipa_verify_edge_has_no_modifications): Declare.
	(ipa_edge_modifications_finalize): Declare.
	* cgraph.c (cgraph_edge::redirect_call_stmt_to_callee): Remove
	performed_splits processing, pas only edge to padjs->modify_call,
	check that call arguments were not modified if they should not have
	been.
	* cgraphclones.c (cgraph_node::create_clone): Do not copy performed
	splits.
	* ipa-param-manipulation.c (struct pass_through_split_map): New type.
	(ipa_edge_modification_info): Likewise.
	(ipa_edge_modification_sum): Likewise.
	(ipa_edge_modifications): New edge summary.
	(ipa_verify_edge_has_no_modifications): New function.
	(transitive_split_p): Removed.
	(transitive_split_map): Likewise.
	(init_transitive_splits): Likewise.
	(ipa_param_adjustments::modify_call): Adjusted to use the new edge
	summary instead of performed_splits.
	(ipa_param_body_adjustments::register_replacement): Drop dummy
	parameter, set base_index of the created ipa_param_body_replacement.
	(phi_arg_will_live_p): New function.
	(ipa_param_body_adjustments::common_initialization): Do not create
	IPA_SRA dummy decls.
	(simple_tree_swap_info): Removed.
	(remap_split_decl_to_dummy): Likewise.
	(record_argument_state_1): New function.
	(record_argument_state): Likewise.
	(ipa_param_body_adjustments::modify_call_stmt): New parameter
	orig_stmt.  Do not work with dummy decls, save necessary info about
	changes to ipa_edge_modifications.
	(ipa_param_body_adjustments::modify_gimple_stmt): New parameter
	orig_stmt, pass it to modify_call_stmt.
	(ipa_param_body_adjustments::modify_cfun_body): Adjust call to
	modify_gimple_stmt.
	(ipa_edge_modifications_finalize): New function.
	* tree-inline.c (remap_gimple_stmt): Pass original statement to
	modify_gimple_stmt.
	(copy_phis_for_bb): Do not copy dead PHI nodes.
	(expand_call_inline): Do not remap performed_splits.
	(update_clone_info): Likewise.
	* toplev.c: Include ipa-param-manipulation.h.
	(toplev::finalize): Call ipa_edge_modifications_finalize.
2021-06-28 18:24:34 +02:00
Jonathan Wakely 084635aa80 libstdc++: Remove redundant explicit instantiations
These function templates are explicitly specialized for char and wchar_t
streambufs, so the explicit instantiations do nothing. Remove them, to
avoid confusion.

libstdc++-v3/ChangeLog:

	* include/bits/streambuf.tcc (__copy_streambufs_eof): Remove
	explicit instantiation declarations.
	* src/c++11/streambuf-inst.cc (__copy_streambufs_eof): Remove
	explicit instantiation definitions.
2021-06-28 15:16:08 +01:00
Jonathan Wakely 75f948f089 libstdc++: Fix backwards logic in 17_intro/names.cc test [PR 97088]
I meant to undef the names that clash with newlib headers for newlib,
but I only undef'd them for non-newlib targets. This means they still
cause errors for newlib, and aren't tested for other targets.

This fixes the test to check those names for non-newlib targets, and to
undef them to avoid errors for newlib.

libstdc++-v3/ChangeLog:

	PR libstdc++/97088
	* testsuite/17_intro/names.cc: Fix #if condition for names used
	by newlib headers.
2021-06-28 15:15:16 +01:00
Jonathan Wakely b7a89c041a libstdc++: Allow unique_ptr<Incomplete[]>::operator[] [PR 101236]
PR libstdc++/101236 shows that LLVM depends on being able to use
unique_ptr<T[]>::operator[] when T is incomplete. This is undefined, but
previously worked with libstdc++. When I added the conditional noexcept
to that operator we started to diagnose the incomplete type.

This change restores support for that case, by making the noexcept
condition check that the type is complete before checking whether
indexing on the pointer can throw.  A workaround for PR c++/101239 is
needed to avoid a bogus error where G++ fails to do SFINAE on the
ill-formed p[n] expression and gets an ICE. Instead of checking that the
p[n] expression is valid in the trailing-return-type, we only check that
the element_type is complete.

libstdc++-v3/ChangeLog:

	PR libstdc++/101236
	* include/bits/unique_ptr.h (unique_ptr<T[], D>::operator[]):
	Fail gracefully if element_type is incomplete.
	* testsuite/20_util/unique_ptr/cons/incomplete.cc: Clarify that
	the standard doesn't require this test to work for array types.
	* testsuite/20_util/unique_ptr/lwg2762.cc: Check that incomplete
	types can be used with array specialization.
	* testsuite/20_util/unique_ptr/101236.cc: New test.
2021-06-28 14:20:55 +01:00
Jonathan Wakely e5c422b7d8 libstdc++: Implement LWG 415 for std::ws
For C++11 std::ws changed to be an unformatted input function, meaning
it constructs a sentry and sets badbit on exceptions.

libstdc++-v3/ChangeLog:

	* doc/xml/manual/intro.xml: Document LWG 415 change.
	* doc/html/manual/bugs.html: Regenerate.
	* include/bits/istream.tcc (ws): Create sentry and catch
	exceptions.
	* testsuite/27_io/basic_istream/ws/char/lwg415.cc: New test.
	* testsuite/27_io/basic_istream/ws/wchar_t/lwg415.cc: New test.
2021-06-28 13:34:49 +01:00
Martin Liska b838641bb0 mklog: Handle correctly long lines.
contrib/ChangeLog:

	* mklog.py: Handle correctly long lines.
	* test_mklog.py: Test it.
2021-06-28 13:43:41 +02:00
Andrew Pinski 9fe9c45ae3 Duplicate the range information of the phi onto the new ssa_name
Since match_simplify_replacement uses gimple_simplify, there is a new
ssa name created sometimes and then we go and replace the phi edge with
this new ssa name, the range information on the phi is lost.
Placing this in replace_phi_edge_with_variable is the best option instead
of doing it in each time replace_phi_edge_with_variable is called which is
what is done today.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

	* tree-ssa-phiopt.c (replace_phi_edge_with_variable): Duplicate range
	info if we're the only things setting the target PHI.
	(value_replacement): Don't duplicate range here.
	(minmax_replacement): Likewise.
2021-06-28 03:06:37 -07:00
Richard Biener f80c4eaca0 tree-optimization/101229 - fix vectorizer SLP hybrid detection with PHIs
This fixes the missing handling of PHIs in gimple_walk_op which causes
the new vectorizer SLP hybrid detection scheme to fail.

2021-06-28  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/101229
	* gimple-walk.c (gimple_walk_op): Handle PHIs.

	* gcc.dg/torture/pr101229.c: New testcase.
2021-06-28 11:55:24 +02:00
Martin Liska ad26c076aa v850: silent 2 warnings
Silents:

/home/marxin/Programming/gcc/gcc/config/v850/v850.c: In function ‘char* construct_dispose_instruction(rtx)’:
/home/marxin/Programming/gcc/gcc/config/v850/v850.c:2690:22: warning: ‘%s’ directive writing up to 99 bytes into a region of size between 79 and 89 [-Wformat-overflow=]
 2690 |       sprintf (buff, "dispose %d {%s}, r31", stack_bytes / 4, regs);
      |                      ^~~~~~~~~~~~~~~~~~~~~~                   ~~~~
/home/marxin/Programming/gcc/gcc/config/v850/v850.c:2690:15: note: ‘sprintf’ output between 18 and 127 bytes into a destination of size 100
 2690 |       sprintf (buff, "dispose %d {%s}, r31", stack_bytes / 4, regs);
      |       ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/marxin/Programming/gcc/gcc/config/v850/v850.c: In function ‘char* construct_prepare_instruction(rtx)’:
/home/marxin/Programming/gcc/gcc/config/v850/v850.c:2814:22: warning: ‘%s’ directive writing up to 99 bytes into a region of size 91 [-Wformat-overflow=]
 2814 |       sprintf (buff, "prepare {%s}, %d", regs, (- stack_bytes) / 4);
      |                      ^~~~~~~~~~~~~~~~~~  ~~~~
/home/marxin/Programming/gcc/gcc/config/v850/v850.c:2814:15: note: ‘sprintf’ output between 14 and 123 bytes into a destination of size 100
 2814 |       sprintf (buff, "prepare {%s}, %d", regs, (- stack_bytes) / 4);
      |       ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

gcc/ChangeLog:

	* config/v850/v850.c (construct_dispose_instruction): Allocate
	a bigger buffer.
	(construct_prepare_instruction): Likewise.
2021-06-28 11:28:07 +02:00
Martin Liska 22069036ef v850: add v850_can_inline_p target hook
gcc/ChangeLog:

	* config/v850/v850.c (v850_option_override): Build default
	target node.
	(v850_can_inline_p): New.  Allow MASK_PROLOG_FUNCTION to be
	ignored for inlining.
	(TARGET_CAN_INLINE_P): New.
2021-06-28 11:28:03 +02:00
Richard Biener 2ad71efb5d tree-optimization/101207 - fix BB reduc permute elide with life stmts
This fixes breakage of live lane extracts from permuted loads we elide
from BB reduction vectorization by handling the un-permuting the same
as in the regular eliding code - apply the reverse permute to
both the scalar stmts and the load permutation.

2021-06-28  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/101207
	* tree-vect-slp.c (vect_optimize_slp): Do BB reduction
	permute eliding for load permutations properly.

	* gcc.dg/vect/bb-slp-pr101207.c: New testcase.
2021-06-28 09:42:58 +02:00
Richard Biener 0ad9d88a3d tree-optimization/101173 - fix interchange dependence checking
This adjusts the loop interchange dependence checking to disallow
an outer loop dependence distance of zero.

2021-06-23  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/101173
	* gimple-loop-interchange.cc
	(tree_loop_interchange::valid_data_dependences): Disallow outer
	loop dependence distance of zero.

	* gcc.dg/torture/pr101173.c: New testcase.
2021-06-28 08:33:06 +02:00
liuhongt 3f1a08d9d7 For 128/256-bit vec_cond_expr, When mask operands is lt reg const0_rtx, blendv can be used instead of avx512 mask.
gcc/ChangeLog:

	PR target/100648
	* config/i386/sse.md (*avx_cmp<mode>3_lt): New
	define_insn_and_split.
	(*avx_cmp<mode>3_ltint): Ditto.
	(*avx2_pcmp<mode>3_3): Ditto.
	(*avx2_pcmp<mode>3_4): Ditto.
	(*avx2_pcmp<mode>3_5): Ditto.

gcc/testsuite/ChangeLog:

	PR target/100648
	* g++.target/i386/avx2-pr54700-2.C: Adjust testcase.
	* g++.target/i386/avx512vl-pr54700-1a.C: New test.
	* g++.target/i386/avx512vl-pr54700-1b.C: New test.
	* g++.target/i386/avx512vl-pr54700-2a.C: New test.
	* g++.target/i386/avx512vl-pr54700-2b.C: New test.
	* gcc.target/i386/avx512vl-pr100648.c: New test.
	* gcc.target/i386/avx512vl-blendv-1.c: New test.
	* gcc.target/i386/avx512vl-blendv-2.c: New test.
2021-06-28 09:17:36 +08:00
liuhongt 28560c6d40 Fold blendv builtins into gimple.
Fold __builtin_ia32_pblendvb128 (a, b, c) as VEC_COND_EXPR (c < 0, b,
a), similar for float version but with mask operand VIEW_CONVERT_EXPR
to same sized integer vectype.

gcc/ChangeLog:

	* config/i386/i386-builtin.def (IX86_BUILTIN_BLENDVPD256,
	IX86_BUILTIN_BLENDVPS256, IX86_BUILTIN_PBLENDVB256,
	IX86_BUILTIN_BLENDVPD, IX86_BUILTIN_BLENDVPS,
	IX86_BUILTIN_PBLENDVB128): Replace icode with
	CODE_FOR_nothing.
	* config/i386/i386.c (ix86_gimple_fold_builtin): Fold blendv
	builtins.
	* config/i386/sse.md (*<sse4_1_avx2>_pblendvb_lt_subreg_not):
	New pre_reload splitter.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/funcspec-8.c: Replace
	__builtin_ia32_blendvpd with  __builtin_ia32_roundps_az.
	* gcc.target/i386/blendv-1.c: New test.
	* gcc.target/i386/blendv-2.c: New test.
2021-06-28 09:15:40 +08:00
GCC Administrator a766c79fc6 Daily bump. 2021-06-28 00:16:30 +00:00
Andrew Pinski 37ad257c06 Fix PR 101230: ICE in fold_cond_expr_with_comparison
This fixes PR 101230 where I had messed up and forgot that
invert_tree_comparison can return ERROR_MARK if the comparsion
is not invertable (floating point types).

Committed as obvious after a bootstrap/test on x86_64-linux-gnu-gnu

gcc/ChangeLog:

	PR middle-end/101230
	* fold-const.c (fold_ternary_loc): Check
	the return value of invert_tree_comparison.

gcc/testsuite/ChangeLog:

	* gcc.dg/torture/pr101230-1.c: New test.
2021-06-27 16:14:29 -07:00
David Edelsohn 3966726333 aix: Add AIX 7.3 configuration and SPDX License Identifiers.
The anticipated release of AIX 7.3 has been announced.  This
	patch adds the configuration bits based on AIX 7.2 configuration.

gcc/ChangeLog:

	* config.gcc: Add SPDX License Identifier.
	(powerpc-ibm-aix789): Default to aix73.h.
	(powerpc-ibm-aix7.2.*.*): New stanza.
	* config/rs6000/aix72.h: Add SPDX License Identifier.
	* config/rs6000/aix73.h: New file.
2021-06-27 16:30:29 -04:00
GCC Administrator 461f937b47 Daily bump. 2021-06-27 00:16:24 +00:00
Patrick Palka 9f26e34a5a c++: access scope during partial spec matching [PR96204]
Here, when determining whether the partial specialization matches
has_type_member<Child>, we do so from the scope of where the template-id
appears rather than from the scope of the specialization, and this
causes us to select the partial specialization (since Child::type is
accessible from Parent).  When we later instantiate this partial
specialization, we've entered the scope of the specialization and so
substitution into e.g. the DECL_CONTEXT of has_type_member::value fails
with access errors since the friend declaration that we relied on to
choose the partial specialization no longer applies.

It seems the appropriate access scope from which to perform partial
specialization matching is the specialization itself (similar to how
we check access of base-clauses), which is what this patch implements.

	PR c++/96204

gcc/cp/ChangeLog:

	* pt.c (instantiate_class_template_1): Enter the scope of the
	type when calling most_specialized_partial_spec.

gcc/testsuite/ChangeLog:

	* g++.dg/template/access40.C: New test.
	* g++.dg/template/access40a.C: New test.
2021-06-26 11:05:54 -04:00
Jason Merrill 5b1ce655b2 except: remove dwarf2out.h dependency
When thinking about the CTF debug patchset dwarf2out.h split, I noticed that
except.c only needs macros from dwarf2.h, nothing from dwarf2out.h.

gcc/ChangeLog:

	* except.c: #include "dwarf2.h" instead of "dwarf2out.h".
2021-06-26 00:17:43 -04:00
Jason Merrill 2168bfb814 c++: constexpr aggr init of empty class [PR101040]
This is basically the aggregate initializer version of PR97566; as in that
bug, we are trying to initialize empty field 'obj' in 'single' when there's
no CONSTRUCTOR entry for the 'single' base class subobject of 'derived'.  As
with that bug, the fix is to stop trying to add entries for empty fields,
this time in cxx_eval_bare_aggregate.

The change to the other function isn't necessary for this version of
the patch, but seems worthwhile for robustness anyway.

	PR c++/101040
	PR c++/97566

gcc/cp/ChangeLog:

	* class.c (is_empty_field): Handle null argument.
	* constexpr.c (cxx_eval_bare_aggregate): Discard initializer
	for empty field.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/no_unique_address13.C: New test.
2021-06-26 00:13:46 -04:00
Andrew Pinski 2afe882858 Lower for loops before lowering cond in genmatch
While converting some fold_cond_expr_with_comparison
to match, I found that I wanted to use "for cnd (cond vec_cond)"
but that was not causing the lowering of cond to happen.
What was happening was the lowering of the for loop
was happening after the lowering of the cond. So
swapping was the correct thing to do but it also
means we need to copy for_subst_vec in lower_cond.

OK?  Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

	* genmatch.c (lower_cond): Copy for_subst_vec
	for the simplify also.
	(lower): Swap the order for lower_for and lower_cond.
2021-06-25 18:51:52 -07:00
Andrew Pinski fbad6c6252 Reset the range info on the moved instruction in PHIOPT
I had missed this when wrote the patch which allowed the
gimple to be moved from inside the conditional as it.  It
was also missed in the review.  Anyways the range information
needs to be reset for the moved gimple as it was under a
conditional and the flow has changed to be unconditional.
I have not seen any testcase in the wild that produces wrong code
yet which is why there is no testcase but this is similar to what
the other code in phiopt does so after moving those to match, there
might be some.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

	* tree-ssa-phiopt.c (match_simplify_replacement): Reset
	flow senatitive info on the moved ssa set.
2021-06-25 18:47:42 -07:00
Andrew Pinski 86fc076dc2 Expand the comparison argument of fold_cond_expr_with_comparison
To make things slightly easiler to convert fold_cond_expr_with_comparison
over to match.pd, expanding the arg0 argument into 3 different arguments
is done. Also this was simple because we don't use arg0 after grabbing
the code and the two operands.
Also since we do this, we don't need to fold the comparison to
get the inverse but just use invert_tree_comparison directly.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

	* fold-const.c (fold_cond_expr_with_comparison):
	Exand arg0 into comp_code, arg00, and arg01.
	(fold_ternary_loc): Use invert_tree_comparison
	instead of fold_invert_truthvalue for the case
	where we have A CMP B ? C : A.
2021-06-25 18:47:42 -07:00
GCC Administrator 90708f87b8 Daily bump. 2021-06-26 00:16:39 +00:00
Marek Polacek f9c80eb12c c++: Failure to delay noexcept parsing with ptr-operator [PR100752]
We weren't passing 'flags' to the recursive call to cp_parser_declarator
in the ptr-operator case and as an effect, delayed parsing of noexcept
didn't work as advertised.  The following change passes more than just
CP_PARSER_FLAGS_DELAY_NOEXCEPT but that doesn't seem to break anything.

I'm now also passing member_p and static_p, as a consequence, two tests
needed small tweaks.

	PR c++/100752

gcc/cp/ChangeLog:

	* parser.c (cp_parser_declarator): Pass flags down to
	cp_parser_declarator.  Also pass static_p/member_p.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/noexcept69.C: New test.
	* g++.dg/parse/saved1.C: Adjust dg-error.
	* g++.dg/template/crash50.C: Likewise.
2021-06-25 20:12:04 -04:00
David Malcolm 99585d88a0 jit: fix test-vector-* failures
Fix failures seen on i686 due to relying on exact floating-point
equality when testing results of vector division.

gcc/testsuite/ChangeLog:
	* jit.dg/test-vector-rvalues.cc (check_div): Add specialization
	for v4f, to avoid relying on exact floating-point equality.
	* jit.dg/test-vector-types.cc (check_div): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2021-06-25 19:07:30 -04:00
David Malcolm 176289e50e jit: fix test-asm failures on i?86
On i686, test_i386_basic_asm_4 has:
  error: inconsistent operand constraints in an 'asm'
and test_i386_basic_asm_5 has:
  /tmp/libgccjit-9FsLie/fake.s:9: Error: bad register name `%rdi'
  /tmp/libgccjit-9FsLie/fake.s:10: Error: bad register name `%rsi'

This is only intended as a smoketest of asm support, so only run
it on x86_64.

gcc/testsuite/ChangeLog:
	* jit.dg/test-asm.c: Remove i?86-*-* from target specifier.
	* jit.dg/test-asm.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2021-06-25 19:07:25 -04:00
Martin Sebor fd51b344ca PR middle-end/101216 - spurious notes for function calls
PR middle-end/101216

gcc/ChangeLog:

	* calls.c (maybe_warn_rdwr_sizes): Use the no_warning constant.

gcc/testsuite/ChangeLog:

	* gcc.dg/Wnonnull-7.c: New test.
2021-06-25 17:01:01 -06:00
Jonathan Wakely 4a52cf2eb9 libstdc++: Avoid intercepting exception in ostream::write
Currently if ostream::write fails and sets badbit and that causes an
exception, we will catch the exception, set badbit again, and rethrow
the exception.

This change delays setting badbit until after the try-catch block, so
that if it causes an exception we don't need to catch and rethrow it.

This removes the last remaining use of _M_write, so it can be made
private (or removed entirely for versioned namespace builds, where ABI
compatibility is not required). All other uses of _M_write were replaced
by calls to __ostream_insert, so make _M_write use that too.

libstdc++-v3/ChangeLog:

	* include/bits/ostream.tcc (basic_ostream::write): Call sputn
	directly instead of using _M_write. Do setstate(__err) all
	outside the try-catch block.
	* include/std/ostream (basic_ostream::_M_write): Declare
	private. Use __ostream_insert. Do not define for the versioned
	namespace.
2021-06-25 18:47:44 +01:00
Jonathan Wakely f8c5b542f6 libstdc++: Implement LWG 581 for std:ostream::flush()
LWG 581 changed ostream::flush() to an unformatted output function for
C++11, but it was never implemented in libstdc++.

libstdc++-v3/ChangeLog:

	* doc/xml/manual/intro.xml: Document LWG 581 change.
	* doc/html/manual/bugs.html: Regenerate.
	* include/bits/basic_ios.tcc: Whitespace.
	* include/bits/ostream.tcc (basic_ostream::flush()): Construct
	sentry.
	* testsuite/27_io/basic_ostream/flush/char/2.cc: Check
	additional cases.
	* testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc:
	Likewise.
	* testsuite/27_io/basic_ostream/flush/wchar_t/2.cc: Likewise.
	* testsuite/27_io/basic_ostream/flush/wchar_t/exceptions_badbit_throw.cc:
	Likewise.
2021-06-25 18:47:39 +01:00
Jonathan Wakely 9b6c65c754 libstdc++: Fix exception handling in std::ostream seek functions
N3168 added the requirement that the [ostream.seeks] functions create a
sentry object. Nothing in the requirements of those functions says
anything about catching exceptions and setting badbit.

As well as not catching exceptions, this change results in another
observable behaviour change. Previously seeking on a stream with eofbit
set would work (as long as badbit and failbit weren't set). The
construction of a sentry causes failbit to be set when eofbit is set,
which causes the seek to fail. It is necessary to clear the eofbit
before seeking now.

libstdc++-v3/ChangeLog:

	* include/bits/ostream.tcc (sentry): Only set failbit if badbit
	is set, not if eofbit is set.
	(tellp, seekp, seekp): Create sentry object. Do not set badbit
	on exceptions.
	* testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc:
	Adjust expected behaviour.
	* testsuite/27_io/basic_ostream/seekp/wchar_t/exceptions_badbit_throw.cc:
	Likewise.
	* testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc:
	Likewise.
	* testsuite/27_io/basic_ostream/tellp/wchar_t/exceptions_badbit_throw.cc:
	Likewise.
	* testsuite/27_io/basic_ostream/seekp/char/n3168.cc: New test.
	* testsuite/27_io/basic_ostream/seekp/wchar_t/n3168.cc: New test.
	* testsuite/27_io/basic_ostream/tellp/char/n3168.cc: New test.
	* testsuite/27_io/basic_ostream/tellp/wchar_t/n3168.cc: New test.
2021-06-25 18:47:23 +01:00
Jonathan Wakely 7ab7fa1b51 libstdc++: Remove noexcept from syncbuf::swap (LWG 3498)
The proposed resolution for the inconsistent noexcept-specifiers in the
spec is to remove it from bto hthe assignment operator and swap.

libstdc++-v3/ChangeLog:

	* include/std/syncstream (basic_syncbuf::swap()): Remove
	noexcept, as per LWG 3498.
2021-06-25 18:41:30 +01:00
Jonathan Wakely e83a5a6b68 libstdc++: More workarounds in 17_intro/names.cc test [PR 97088]
Conditionally #undef some more names that are used in system headers.

libstdc++-v3/ChangeLog:

	PR libstdc++/97088
	* testsuite/17_intro/names.cc: Undef more names for newlib and
	also for arm-none-linux-gnueabi.
	* testsuite/experimental/names.cc: Disable PCH.
2021-06-25 18:41:24 +01:00
Chung-Lin Tang e067201737 testsuite/101114: Adjust libgomp.c-c++-common/struct-elem-5.c testcase
The dg-shouldfail testcase libgomp.c-c++-common/struct-elem-5.c does not
properly fail for non-shared address space offloading. Adjust testcase
to limit testing only for "target offload_device_nonshared_as".

libgomp/ChangeLog:

	PR testsuite/101114
	* testsuite/libgomp.c-c++-common/struct-elem-5.c:
	Add "target offload_device_nonshared_as" condition for enabling test.
2021-06-26 00:46:11 +08:00
Matthias Kretz 74ebd1297e libstdc++: Make use of __builtin_bit_cast for simd
The __bit_cast function was a hack to achieve what __builtin_bit_cast
can do, therefore use __builtin_bit_cast if possible. However,
__builtin_bit_cast cannot be used to cast from/to fixed_size_simd, since
it isn't trivially copyable (in the language sense — in principle it
is). Therefore add __proposed::simd_bit_cast to enable the use case
required in the test framework.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd.h (__bit_cast): Implement via
	__builtin_bit_cast #if available.
	(__proposed::simd_bit_cast): Add overloads for simd and
	simd_mask, which use __builtin_bit_cast (or __bit_cast #if not
	available), which return an object of the requested type with
	the same bits as the argument.
	* include/experimental/bits/simd_math.h: Use simd_bit_cast
	instead of __bit_cast to allow casts to fixed_size_simd.
	(copysign): Remove branch that was only required if __bit_cast
	cannot be constexpr.
	* testsuite/experimental/simd/tests/bits/test_values.h: Switch
	from __bit_cast to __proposed::simd_bit_cast since the former
	will not cast fixed_size objects anymore.
2021-06-25 17:32:13 +02:00
Matthias Kretz 3c34746794 MAINTAINERS: Add myself for write after approval and DCO
Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

ChangeLog:

	* MAINTAINERS: Add myself for write after approval and DCO
2021-06-25 15:59:15 +02:00
Jeff Law 3a50aed09e Use right shifts to eliminate redundant test/compare insns on the H8
gcc/
	* config/h8300/h8300.c (select_cc_mode): Handle ASHIFTRT and LSHIFTRT.
2021-06-25 09:22:28 -04:00
Richard Biener 55a1546b73 tree-optimization/101202 - fix ICE with failed backedge SLP nodes
This fixes an ICE with failed backedge SLP nodes still in the graph
while doing permute optimization by explicitely handling those.

2021-06-25  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/101202
	* tree-vect-slp.c (vect_optimize_slp): Explicitely handle
	failed nodes.

	* gcc.dg/torture/pr101202.c: New testcase.
2021-06-25 12:03:23 +02:00
Richard Biener 05516402f8 Fixup reduction info on addsub SLP pattern
gcc.dg/vect/pr96854.c shows we need to copy over reduction info
to the SLP pattern as already done for the complex patterns.

2021-06-25  Richard Biener  <rguenther@suse.de>

	* tree-vect-slp-patterns.c (addsub_pattern::build): Copy
	STMT_VINFO_REDUC_DEF from the original representative.
2021-06-25 10:18:56 +02:00
Richard Biener c6c7ac0499 add -ltrans-objects lto-plugin debug option
This adds a -ltrans-objects option to lto-plugin that by-passes
lto-wrapper invocation and instead feeds LD the final LTRANS objects
directly from the response file given as argument to the option.
This allows LD issues involving the linker-plugin path to be
debugged in an easier way with just the IR objects (their symtab)
and the LTRANS objects as testcase.

I've tested the path re-building stage2 build/genmatch from an
LTO bootstrap and got a bit-identical executable by adding
-plugin-opt=-ltrans-objects=y to the original collect2 invocation,
seeding y with the final objects as printed by building genmatch
with -save-temps -v.

2021-06-22  Richard Biener  <rguenther@suse.de>

lto-plugin/
	* lto-plugin.c (ltrans_objects): New global.
	(all_symbols_read_handler): If -ltrans-objects was specified,
	add the output files from the specified file directly.
	(process_option): Handle -ltrans-objects.
2021-06-25 08:48:52 +02:00
Xi Ruoyao 607c558804
testsuite: avoid no-stack-protector-attr-3 fail on mips*-*-*
On MIPS a call to __stack_chk_fail needs an additional .reloc pseudo-op,
so "stack_chk_fail" will appear two times.

gcc/testsuite/

	* g++.dg/no-stack-protector-attr-3.C (dg-final): Adjust for MIPS.
2021-06-25 10:31:31 +08:00
Martin Sebor e9e2bad725 middle-end: add support for per-location warning groups.
gcc/ChangeLog:

	* builtins.c (warn_string_no_nul): Replace uses of TREE_NO_WARNING,
	gimple_no_warning_p and gimple_set_no_warning with
	warning_suppressed_p, and suppress_warning.
	(c_strlen): Same.
	(maybe_warn_for_bound): Same.
	(warn_for_access): Same.
	(check_access): Same.
	(expand_builtin_strncmp): Same.
	(fold_builtin_varargs): Same.
	* calls.c (maybe_warn_nonstring_arg): Same.
	(maybe_warn_rdwr_sizes): Same.
	* cfgexpand.c (expand_call_stmt): Same.
	* cgraphunit.c (check_global_declaration): Same.
	* fold-const.c (fold_undefer_overflow_warnings): Same.
	(fold_truth_not_expr): Same.
	(fold_unary_loc): Same.
	(fold_checksum_tree): Same.
	* gimple-array-bounds.cc (array_bounds_checker::check_array_ref): Same.
	(array_bounds_checker::check_mem_ref): Same.
	(array_bounds_checker::check_addr_expr): Same.
	(array_bounds_checker::check_array_bounds): Same.
	* gimple-expr.c (copy_var_decl): Same.
	* gimple-fold.c (gimple_fold_builtin_strcpy): Same.
	(gimple_fold_builtin_strncat): Same.
	(gimple_fold_builtin_stxcpy_chk): Same.
	(gimple_fold_builtin_stpcpy): Same.
	(gimple_fold_builtin_sprintf): Same.
	(fold_stmt_1): Same.
	* gimple-ssa-isolate-paths.c (diag_returned_locals): Same.
	* gimple-ssa-nonnull-compare.c (do_warn_nonnull_compare): Same.
	* gimple-ssa-sprintf.c (handle_printf_call): Same.
	* gimple-ssa-store-merging.c (imm_store_chain_info::output_merged_store): Same.
	* gimple-ssa-warn-restrict.c (maybe_diag_overlap): Same.
	* gimple-ssa-warn-restrict.h: Adjust declarations.
	(maybe_diag_access_bounds): Replace uses of TREE_NO_WARNING,
	gimple_no_warning_p and gimple_set_no_warning with
	warning_suppressed_p, and suppress_warning.
	(check_call): Same.
	(check_bounds_or_overlap): Same.
	* gimple.c (gimple_build_call_from_tree): Same.
	* gimplify.c (gimplify_return_expr): Same.
	(gimplify_cond_expr): Same.
	(gimplify_modify_expr_complex_part): Same.
	(gimplify_modify_expr): Same.
	(gimple_push_cleanup): Same.
	(gimplify_expr): Same.
	* omp-expand.c (expand_omp_for_generic): Same.
	(expand_omp_taskloop_for_outer): Same.
	* omp-low.c (lower_rec_input_clauses): Same.
	(lower_lastprivate_clauses): Same.
	(lower_send_clauses): Same.
	(lower_omp_target): Same.
	* tree-cfg.c (pass_warn_function_return::execute): Same.
	* tree-complex.c (create_one_component_var): Same.
	* tree-inline.c (remap_gimple_op_r): Same.
	(copy_tree_body_r): Same.
	(declare_return_variable): Same.
	(expand_call_inline): Same.
	* tree-nested.c (lookup_field_for_decl): Same.
	* tree-sra.c (create_access_replacement): Same.
	(generate_subtree_copies): Same.
	* tree-ssa-ccp.c (pass_post_ipa_warn::execute): Same.
	* tree-ssa-forwprop.c (combine_cond_expr_cond): Same.
	* tree-ssa-loop-ch.c (ch_base::copy_headers): Same.
	* tree-ssa-loop-im.c (execute_sm): Same.
	* tree-ssa-phiopt.c (cond_store_replacement): Same.
	* tree-ssa-strlen.c (maybe_warn_overflow): Same.
	(handle_builtin_strcpy): Same.
	(maybe_diag_stxncpy_trunc): Same.
	(handle_builtin_stxncpy_strncat): Same.
	(handle_builtin_strcat): Same.
	* tree-ssa-uninit.c (get_no_uninit_warning): Same.
	(set_no_uninit_warning): Same.
	(uninit_undefined_value_p): Same.
	(warn_uninit): Same.
	(maybe_warn_operand): Same.
	* tree-vrp.c (compare_values_warnv): Same.
	* vr-values.c (vr_values::extract_range_for_var_from_comparison_expr): Same.
	(test_for_singularity): Same.

	* gimple.h (warning_suppressed_p): New function.
	(suppress_warning): Same.
	(copy_no_warning): Same.
	(gimple_set_block): Call gimple_set_location.
	(gimple_set_location): Call copy_warning.
2021-06-24 19:30:47 -06:00
Martin Sebor 65870e7561 cp: add support for per-location warning groups.
gcc/cp/ChangeLog:

	* call.c (build_over_call): Replace direct uses of TREE_NO_WARNING
	with warning_suppressed_p, suppress_warning, and copy_no_warning, or
	nothing if not necessary.
	(set_up_extended_ref_temp): Same.
	* class.c (layout_class_type): Same.
	* constraint.cc (constraint_satisfaction_value): Same.
	* coroutines.cc (finish_co_await_expr): Same.
	(finish_co_yield_expr): Same.
	(finish_co_return_stmt): Same.
	(build_actor_fn): Same.
	(coro_rewrite_function_body): Same.
	(morph_fn_to_coro): Same.
	* cp-gimplify.c (genericize_eh_spec_block): Same.
	(gimplify_expr_stmt): Same.
	(cp_genericize_r): Same.
	(cp_fold): Same.
	* cp-ubsan.c (cp_ubsan_instrument_vptr): Same.
	* cvt.c (cp_fold_convert): Same.
	(convert_to_void): Same.
	* decl.c (wrapup_namespace_globals): Same.
	(grokdeclarator): Same.
	(finish_function): Same.
	(require_deduced_type): Same.
	* decl2.c (no_linkage_error): Same.
	(c_parse_final_cleanups): Same.
	* except.c (expand_end_catch_block): Same.
	* init.c (build_new_1): Same.
	(build_new): Same.
	(build_vec_delete_1): Same.
	(build_vec_init): Same.
	(build_delete): Same.
	* method.c (defaultable_fn_check): Same.
	* parser.c (cp_parser_fold_expression): Same.
	(cp_parser_primary_expression): Same.
	* pt.c (push_tinst_level_loc): Same.
	(tsubst_copy): Same.
	(tsubst_omp_udr): Same.
	(tsubst_copy_and_build): Same.
	* rtti.c (build_if_nonnull): Same.
	* semantics.c (maybe_convert_cond): Same.
	(finish_return_stmt): Same.
	(finish_parenthesized_expr): Same.
	(cp_check_omp_declare_reduction): Same.
	* tree.c (build_cplus_array_type): Same.
	* typeck.c (build_ptrmemfunc_access_expr): Same.
	(cp_build_indirect_ref_1): Same.
	(cp_build_function_call_vec): Same.
	(warn_for_null_address): Same.
	(cp_build_binary_op): Same.
	(unary_complex_lvalue): Same.
	(cp_build_modify_expr): Same.
	(build_x_modify_expr): Same.
	(convert_for_assignment): Same.
2021-06-24 19:23:43 -06:00
Martin Sebor 43c3f96f29 c-family: add support for per-location warning groups.
gcc/c-family/ChangeLog:

	* c-common.c (c_wrap_maybe_const): Remove TREE_NO_WARNING.
	(c_common_truthvalue_conversion): Replace direct uses of
	TREE_NO_WARNING with warning_suppressed_p, suppress_warning, and
	copy_no_warning.
	(check_function_arguments_recurse): Same.
	* c-gimplify.c (c_gimplify_expr): Same.
	* c-warn.c (overflow_warning): Same.
	(warn_logical_operator): Same.
	(warn_if_unused_value): Same.
	(do_warn_unused_parameter): Same.
2021-06-24 19:23:43 -06:00
Martin Sebor 1ebd2b2c94 c: add support for per-location warning groups.
gcc/ChangeLog:
	* tree.h (warning_suppressed_at, copy_warning,
	warning_suppressed_p, suppress_warning): New functions.

gcc/c/ChangeLog:

	* c-decl.c (pop_scope): Replace direct uses of TREE_NO_WARNING with
	warning_suppressed_p, suppress_warning, and copy_no_warning.
	(diagnose_mismatched_decls): Same.
	(duplicate_decls): Same.
	(grokdeclarator): Same.
	(finish_function): Same.
	(c_write_global_declarations_1): Same.
	* c-fold.c (c_fully_fold_internal): Same.
	* c-parser.c (c_parser_expr_no_commas): Same.
	(c_parser_postfix_expression): Same.
	* c-typeck.c (array_to_pointer_conversion): Same.
	(function_to_pointer_conversion): Same.
	(default_function_array_conversion): Same.
	(convert_lvalue_to_rvalue): Same.
	(default_conversion): Same.
	(build_indirect_ref): Same.
	(build_function_call_vec): Same.
	(build_atomic_assign): Same.
	(build_unary_op): Same.
	(c_finish_return): Same.
	(emit_side_effect_warnings): Same.
	(c_finish_stmt_expr): Same.
	(c_omp_clause_copy_ctor): Same.
2021-06-24 19:23:43 -06:00