183393 Commits

Author SHA1 Message Date
GCC Administrator
c5ae38e8dc Daily bump. 2021-02-15 00:16:18 +00:00
Jan Hubicka
9966699d7a Fix memory leak in ipa-refernece
2021-02-14  Jan Hubicka  <hubicka@ucw.cz>
	    Richard Biener  <rguether@suse.de>

	PR ipa/97346
	* ipa-reference.c (ipa_init): Only conditinally initialize
	reference_vars_to_consider.
	(propagate): Conditionally deninitialize reference_vars_to_consider.
	(ipa_reference_write_optimization_summary): Sanity check that
	reference_vars_to_consider is not allocated.
2021-02-14 23:24:44 +01:00
Jonathan Wakely
4e3590d06c libstdc++: Restore <unistd.h> in testsuite_fs.h header [PR 99096]
libstdc++-v3/ChangeLog:

	PR libstdc++/99096
	* testsuite/util/testsuite_fs.h: Always include <unistd.h>.
2021-02-14 20:38:32 +00:00
GCC Administrator
c8656df666 Daily bump. 2021-02-14 00:16:34 +00:00
Levy Hsu
18fabc35f4 RISC-V: Avoid zero/sign extend for volatile loads. Fix for 97417.
This expands sub-word loads as a zero/sign extended load, followed by
a subreg.  This helps eliminate unnecessary zero/sign extend insns after
the load, particularly for volatiles, but also in some other cases.
Testing shows that it gives consistent code size decreases.

Tested with riscv32-elf rv32imac/ilp32 and riscv64-linux rv64gc/lp064d
builds and checks.  Some -gsplit-stack tests fail with the patch, but
this turns out to be an existing bug with the split-stack support that
I hadn't noticed before.  It isn't a bug in this patch.  Ignoring that
there are no regressions.

Committed.

	gcc/
	PR target/97417
	* config/riscv/riscv-shorten-memrefs.c (pass_shorten_memrefs): Add
	extend parameter to get_si_mem_base_reg declaration.
	(get_si_mem_base_reg): Add extend parameter.  Set it.
	(analyze): Pass extend arg to get_si_mem_base_reg.
	(transform): Likewise.  Use it when rewriting mems.
	* config/riscv/riscv.c (riscv_legitimize_move): Check for subword
	loads and emit sign/zero extending load followed by subreg move.
2021-02-13 12:33:44 -08:00
Jim Wilson
a4953810ba RISC-V: Shorten memrefs improvement, partial fix 97417.
We already have a check for riscv_shorten_memrefs in riscv_address_cost.
This adds the same check to riscv_rtx_costs.  Making this work also
requires a change to riscv_compressed_lw_address_p to work before reload
by checking the offset and assuming any pseudo reg is OK.  Testing shows
that this consistently gives small code size reductions.

	gcc/
	PR target/97417
	* config/riscv/riscv.c (riscv_compressed_lw_address_p): Drop early
	exit when !reload_completed.  Only perform check for compressed reg
	if reload_completed.
	(riscv_rtx_costs): In MEM case, when optimizing	for size and
	shorten memrefs, if not compressible, then increase cost.
2021-02-13 12:13:08 -08:00
Jakub Jelinek
05402ca65a passes: Enable split4 with selective scheduling 2 [PR98439]
As mentioned in the PR, we have 5 split passes (+ splitting during final).
split1 is before RA and is unconditional,
split2 is after RA and is gated on optimize > 0,
split3 is before sched2 and is gated on
  defined(INSN_SCHEDULING) && optimize > 0 && flag_schedule_insns_after_reload
split4 is before regstack and is gated on
  HAVE_ATTR_length && defined (STACK_REGS) && !gate (split3)
split5 is before shorten_branches and is gated on
  HAVE_ATTR_length && !defined (STACK_REGS)
and the splitting during final works only when !HAVE_ATTR_length.
STACK_REGS is a macro enabled only on i386/x86_64.

The problem with the following testcase is that split3 before sched2
is the last splitting pass for the target/command line options set,
but selective scheduling unlike normal scheduling can create new
instructions that need to be split, which means we ICE during final as
there are insns that require splitting but nothing split them.

This patch fixes it by doing split4 also when -fselective-scheduling2
is enabled on x86 and split3 has been run.  As that option isn't on
by default, it should slow down compilation only for those that enable
that option.

2021-02-13  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/98439
	* recog.c (pass_split_before_regstack::gate): Enable even when
	pass_split_before_sched2 is enabled if -fselective-scheduling2 is
	on.

	* gcc.target/i386/pr98439.c: New test.
2021-02-13 16:08:29 +01:00
Iain Buclaw
a3b38b7781 d: Merge upstream dmd 7132b3537
Splits out all semantic passes for Dsymbol, Type, and TemplateParameter
nodes into Visitors in separate files, and the copyright years of all
sources have been updated.

Reviewed-on: https://github.com/dlang/dmd/pull/12190

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd 7132b3537.
	* Make-lang.in (D_FRONTEND_OBJS): Add d/dsymbolsem.o, d/semantic2.o,
	d/semantic3.o, and d/templateparamsem.o.
	* d-compiler.cc (Compiler::genCmain): Update calls to semantic
	entrypoint functions.
	* d-lang.cc (d_parse_file): Likewise.
	* typeinfo.cc (make_frontend_typeinfo): Likewise.
2021-02-13 12:50:45 +01:00
Jakub Jelinek
0f3a743b68 i386: Add combiner splitter to optimize V2SImode memory rotation [PR96166]
Since the x86 backend enabled V2SImode vectorization (with
TARGET_MMX_WITH_SSE), slp vectorization can kick in and emit
        movq    (%rdi), %xmm1
        pshufd  $225, %xmm1, %xmm0
        movq    %xmm0, (%rdi)
instead of
        rolq    $32, (%rdi)
we used to emit (or emit when slp vectorization is disabled).
I think the rotate is both smaller and faster, so this patch adds
a combiner splitter to optimize that back.

2021-02-13  Jakub Jelinek  <jakub@redhat.com>

	PR target/96166
	* config/i386/mmx.md (*mmx_pshufd_1): Add a combine splitter for
	swap of V2SImode elements in memory into DImode memory rotate by 32.

	* gcc.target/i386/pr96166.c: New test.
2021-02-13 10:32:16 +01:00
GCC Administrator
fab095dad5 Daily bump. 2021-02-13 00:16:38 +00:00
Jakub Jelinek
eb64b0b285 testsuite: Restrict gcc.dg/rtl/aarch64/multi-subreg-1.c test to aarch64 only
2021-02-13  Jakub Jelinek  <jakub@redhat.com>

	* gcc.dg/rtl/aarch64/multi-subreg-1.c: Add dg-do compile directive
	and restrict the test to aarch64-*-* target only.
2021-02-13 00:02:28 +01:00
Nathan Sidwell
8c4137c7ea c++: Seed imported bindings [PR 99039]
As mentioned in 99040's fix, we can get inter-module using decls.  If the
using decl is the only reference to an import, we'll have failed to
seed our imports leading to an assertion failure.  The fix is
straight-forwards, check binding contents when seeding imports.

	gcc/cp/
	* module.cc (module_state::write_cluster): Check bindings for
	imported using-decls.
	gcc/testsuite/
	* g++.dg/modules/pr99039_a.C: New.
	* g++.dg/modules/pr99039_b.C: New.
2021-02-12 13:50:03 -08:00
Nathan Sidwell
0c27fe96f8 c++: Register streamed-in decls when new [PR 99040]
With modules one can have using-decls refering to their own scope.  This
is the way to export things from the GMF or from an import.  The
problem was I was using current_ns == CP_DECL_CONTEXT (decl) to
determine whether a decl should be registered in a namespace level or
not.  But that's an inadequate check and we ended up reregistering
decls and creating a circular list.  We should be registering the decl
when first encountered -- whether we bind it is orthogonal to that.

	PR c++/99040
	gcc/cp/
	* module.cc (trees_in::decl_value): Call add_module_namespace_decl
	for new namespace-scope entities.
	(module_state::read_cluster): Don't call add_module_decl here.
	* name-lookup.h (add_module_decl): Rename to ...
	(add_module_namespace_decl): ... this.
	* name-lookup.c (newbinding_bookkeeping): Move into ...
	(do_pushdecl): ... here.  Its only remaining caller.
	(add_module_decl): Rename to ...
	(add_module_namespace_decl): ... here.  Add checking-assert for
	circularity. Don't call newbinding_bookkeeping, just extern_c
	checking and incomplete var checking.
	gcc/testsuite/
	* g++.dg/modules/pr99040_a.C: New.
	* g++.dg/modules/pr99040_b.C: New.
	* g++.dg/modules/pr99040_c.C: New.
	* g++.dg/modules/pr99040_d.C: New.
2021-02-12 13:50:03 -08:00
Nathan Sidwell
8f93e1b892 Expunge namespace-scope IDENTIFIER_TYPE_VALUE & global_type_name [PR 99039]
IDENTIFIER_TYPE_VALUE and friends is a remnant of G++'s C origins.  It
holds elaborated types on identifier-nodes.  While this is fine for C
and for local and class-scopes in C++, it fails badly for namespaces.
In that case a marker 'global_type_node' was used, which essentially
signified 'this is a namespace-scope type *somewhere*', and you'd have
to do a regular name_lookup to find it.  As the parser and
substitution machinery has avanced over the last 25 years or so,
there's not much outside of actual name-lookup that uses that.
Amusingly the IDENTIFIER_HAS_TYPE_VALUE predicate will do an actual
name-lookup and then users would repeat that lookup to find the
now-known to be there type.

Rather late I realized that this interferes with the lazy loading of
module entities, because we were setting IDENTIFIER_TYPE_VALUE to
global_type_node.  But we could be inside some local scope where that
identifier is bound to some local type.  Not good!

Rather than add more cruft to look at an identifier's shadow stack and
alter that as necessary, this takes the approach of removing the
existing cruft.

We nuke the few places outside of name lookup that use
IDENTIFIER_TYPE_VALUE.  Replacing them with either proper name
lookups, alternative sequences, or in some cases asserting that they
(no longer) happen.  Class template instantiation was calling pushtag
after setting IDENTIFIER_TYPE_VALUE in order to stop pushtag creating
an implicit typedef and pushing it, but to get the bookkeeping it
needed.  Let's just do the bookkeeping directly.

Then we can stop having a 'bound at namespace-scope' marker at all,
which means lazy loading won't screw up local shadow stacks.  Also, it
simplifies set_identifier_type_value_with_scope, as it never needs to
inspect the scope stack.  When developing this patch, I discovered a
number of places we'd put an actual namespace-scope type on the
type_value slot, rather than global_type_node.  You might notice this
is killing at least two 'why are we doing this?' comments.

While this doesn't fix the two PRs mentioned, it is a necessary step.

	PR c++/99039
	PR c++/99040
	gcc/cp/
	* cp-tree.h (CPTI_GLOBAL_TYPE): Delete.
	(global_type_node): Delete.
	(IDENTIFIER_TYPE_VALUE): Delete.
	(IDENTIFIER_HAS_TYPE_VALUE): Delete.
	(get_type_value): Delete.
	* name-lookup.h (identifier_type_value): Delete.
	* name-lookup.c (check_module_override): Don't
	SET_IDENTIFIER_TYPE_VALUE here.
	(do_pushdecl): Nor here.
	(identifier_type_value_1, identifier_type_value): Delete.
	(set_identifier_type_value_with_scope): Only
	SET_IDENTIFIER_TYPE_VALUE for local and class scopes.
	(pushdecl_nanmespace_level): Remove shadow stack nadgering.
	(do_pushtag): Use REAL_IDENTIFIER_TYPE_VALUE.
	* call.c (check_dtor_name): Use lookup_name.
	* decl.c (cxx_init_decl_processing): Drop global_type_node.
	* decl2.c (cplus_decl_attributes): Don't SET_IDENTIFIER_TYPE_VALUE
	here.
	* init.c (get_type_value): Delete.
	* pt.c (instantiate_class_template_1): Don't call pushtag or
	SET_IDENTIFIER_TYPE_VALUE here.
	(tsubst): Assert never an identifier.
	(dependent_type_p): Drop global_type_node assert.
	* typeck.c (error_args_num): Don't use IDENTIFIER_HAS_TYPE_VALUE
	to determine ctorness.
	gcc/testsuite/
	* g++.dg/lookup/pr99039.C: New.
2021-02-12 13:50:03 -08:00
Michael Matloob
9769564e74 compiler: open byte slice and string embeds using the absolute path
The paths vector contains the names of the files that the embed_files_
map is keyed by. While the code processing embed.FS values looks up
the paths in the embed_files_ map, the code processing string and byte
slice embeds tries opening the files using their names directly. Look
up the full paths in the embed_files_ map when opening them.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/291429
2021-02-12 11:18:32 -08:00
Martin Sebor
f3d7fd1475 PR c/99055 - memory leak in warn_parm_array_mismatch
gcc/c-family/ChangeLog:

	PR c/99055
	* c-warn.c (warn_parm_array_mismatch): Free strings returned from
	print_generic_expr_to_str.

gcc/ChangeLog:

	* tree-pretty-print.c (print_generic_expr_to_str): Update comment.
2021-02-12 11:18:52 -07:00
Steve Kargl
0631e008ad libgfortran: Fix PR95647 by changing the interfaces of operators .eq. and .ne.
The FE converts the old school .eq. to ==,
and then tracks the ==.  The module starts with == and so it does not
properly overload the .eq.  Reversing the interfaces fixes this.

2021-02-12  Steve Kargl <sgk@troutmask.apl.washington.edu>

libgfortran/ChangeLog:

	PR libfortran/95647
	* ieee/ieee_arithmetic.F90: Flip interfaces of operators .eq. to
	== and .ne. to /= .

gcc/testsuite/ChangeLog:

	PR libfortran/95647
	* gfortran.dg/ieee/ieee_12.f90: New test.
2021-02-12 07:58:16 -08:00
Richard Sandiford
adfee3c4c0 rtl-ssa: Use right obstack for temporary allocation
I noticed while working on PR98863 that we were using the main
obstack to allocate temporary uses.  That was safe, but represents
a kind of local memory leak.

gcc/
	* rtl-ssa/accesses.cc (function_info::make_use_available): Use
	m_temp_obstack rather than m_obstack to allocate the temporary use.
2021-02-12 15:54:49 +00:00
Richard Sandiford
f60226fd72 df: Record all definitions in DF_LR_BB_INFO->def [PR98863]
df_lr_bb_local_compute has:

      FOR_EACH_INSN_INFO_DEF (def, insn_info)
	/* If the def is to only part of the reg, it does
	   not kill the other defs that reach here.  */
	if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))

However, as noted in the comment in the patch and below, almost all
partial definitions have an associated use.  This means that the
confluence function:

  IN = (OUT & ~DEF) | USE

is unaffected by whether partial definitions are in DEF or not.

Even though the choice doesn't matter for the LR problem itself,
it's IMO much more convenient for consumers if DEF contains all the
definitions in the block.  The only pre-RTL-SSA code that tries to
consume DEF directly is shrink-wrap.c, which already has to work
around the incompleteness of the information:

	  /* DF_LR_BB_INFO (bb)->def does not comprise the DF_REF_PARTIAL and
	     DF_REF_CONDITIONAL defs.  So if DF_LIVE doesn't exist, i.e.
	     at -O1, just give up searching NEXT_BLOCK.  */

I hit the same problem when trying to fix the RTL-SSA part of PR98863.

This patch treats partial definitions as both a def and a use,
just like the df_ref records almost always do.

To show that partial definitions almost always have uses:

  DF_REF_CONDITIONAL:

    Added by:

      case COND_EXEC:
	df_defs_record (collection_rec, COND_EXEC_CODE (x),
			bb, insn_info, DF_REF_CONDITIONAL);
	break;

    Later, df_get_conditional_uses creates uses for all DF_REF_CONDITIONAL
    definitions.

  DF_REF_PARTIAL:

    In total, there are 4 locations at which we add partial definitions.

    Case 1:

      if (GET_CODE (dst) == STRICT_LOW_PART)
	{
	  flags |= DF_REF_READ_WRITE | DF_REF_PARTIAL | DF_REF_STRICT_LOW_PART;

	  loc = &XEXP (dst, 0);
	  dst = *loc;
	}

    Corresponding use:

      case STRICT_LOW_PART:
	{
	  rtx *temp = &XEXP (dst, 0);
	  /* A strict_low_part uses the whole REG and not just the
	   SUBREG.  */
	  dst = XEXP (dst, 0);
	  df_uses_record (collection_rec,
			  (GET_CODE (dst) == SUBREG) ? &SUBREG_REG (dst) : temp,
			  DF_REF_REG_USE, bb, insn_info,
			  DF_REF_READ_WRITE | DF_REF_STRICT_LOW_PART);
	}
	break;

    Case 2:

      if (GET_CODE (dst) == ZERO_EXTRACT)
	{
	  flags |= DF_REF_READ_WRITE | DF_REF_PARTIAL | DF_REF_ZERO_EXTRACT;

	  loc = &XEXP (dst, 0);
	  dst = *loc;
	}

    Corresponding use:

      case ZERO_EXTRACT:
	{
	  df_uses_record (collection_rec, &XEXP (dst, 1),
			  DF_REF_REG_USE, bb, insn_info, flags);
	  df_uses_record (collection_rec, &XEXP (dst, 2),
			  DF_REF_REG_USE, bb, insn_info, flags);
	  if (GET_CODE (XEXP (dst,0)) == MEM)
	    df_uses_record (collection_rec, &XEXP (dst, 0),
			    DF_REF_REG_USE, bb, insn_info,
			    flags);
	  else
	    df_uses_record (collection_rec, &XEXP (dst, 0),
			    DF_REF_REG_USE, bb, insn_info,
			    DF_REF_READ_WRITE | DF_REF_ZERO_EXTRACT);
----------------------------^^^^^^^^^^^^^^^^^
	}
	break;

    Case 3:

      else if (GET_CODE (dst) == SUBREG && REG_P (SUBREG_REG (dst)))
	{
	  if (read_modify_subreg_p (dst))
	    flags |= DF_REF_READ_WRITE | DF_REF_PARTIAL;

	  flags |= DF_REF_SUBREG;

	  df_ref_record (DF_REF_REGULAR, collection_rec,
			 dst, loc, bb, insn_info, DF_REF_REG_DEF, flags);
	}

    Corresponding use:

      case SUBREG:
	if (read_modify_subreg_p (dst))
	  {
	    df_uses_record (collection_rec, &SUBREG_REG (dst),
			    DF_REF_REG_USE, bb, insn_info,
			    flags | DF_REF_READ_WRITE | DF_REF_SUBREG);
	    break;
	  }

    Case 4:

      /*  If this is a multiword hardreg, we create some extra
	  datastructures that will enable us to easily build REG_DEAD
	  and REG_UNUSED notes.  */
      if (collection_rec
	  && (endregno != regno + 1) && insn_info)
	{
	  /* Sets to a subreg of a multiword register are partial.
	     Sets to a non-subreg of a multiword register are not.  */
	  if (GET_CODE (reg) == SUBREG)
	    ref_flags |= DF_REF_PARTIAL;
	  ref_flags |= DF_REF_MW_HARDREG;

    Corresponding use:

      None.  However, this case should be rare to non-existent on most
      targets, and the current handling seems suspect.  See the comment
      in the patch for more details.

gcc/
	* df-problems.c (df_lr_bb_local_compute): Treat partial definitions
	as read-modify operations.

gcc/testsuite/
	* gcc.dg/rtl/aarch64/multi-subreg-1.c: New test.
2021-02-12 15:54:48 +00:00
Jonathan Wakely
b7210405ed libstdc++: Re-enable workaround for _wstat64 bug, again [PR 88881]
I forgot that the workaround is present in both filesystem::status and
filesystem::symlink_status. This restores it in the latter.

libstdc++-v3/ChangeLog:

	PR libstdc++/88881
	* src/c++17/fs_ops.cc (fs::symlink_status): Re-enable workaround.
2021-02-12 15:30:35 +00:00
Jonathan Wakely
1dfd95f0a0 libstdc++: Fix filesystem::rename on Windows [PR 98985]
The _wrename function won't overwrite an existing file, so use
MoveFileEx instead. That allows renaming directories over files, which
POSIX doesn't allow, so check for that case explicitly and report an
error.

Also document the deviation from the expected behaviour, and add a test
for filesystem::rename which was previously missing.

The Filesystem TS experimental::filesystem::rename doesn't have that
extra code to handle directories correctly, so the relevant parts of the
new test are not run on Windows.

libstdc++-v3/ChangeLog:

	* doc/xml/manual/status_cxx2014.xml: Document implementation
	specific properties of std::experimental::filesystem::rename.
	* doc/xml/manual/status_cxx2017.xml: Document implementation
	specific properties of std::filesystem::rename.
	* doc/html/*: Regenerate.
	* src/c++17/fs_ops.cc (fs::rename): Implement correct behaviour
	for directories on Windows.
	* src/filesystem/ops-common.h (__gnu_posix::rename): Use
	MoveFileExW on Windows.
	* testsuite/27_io/filesystem/operations/rename.cc: New test.
	* testsuite/experimental/filesystem/operations/rename.cc: New test.
2021-02-12 15:29:50 +00:00
Jonathan Wakely
4179ec1079 libstdc++: Make "nonexistent" paths less predictable in filesystem tests
The helper function for creating new paths doesn't work well on Windows,
because the PID of a process started by Wine is very consistent and so
the same path gets created each time.

libstdc++-v3/ChangeLog:

	* testsuite/util/testsuite_fs.h (nonexistent_path): Add
	random number to the path.
2021-02-12 15:13:02 +00:00
Jonathan Wakely
d1a821b93c libstdc++: Include scope ID in net::internet::address_v6::to_string()
libstdc++-v3/ChangeLog:

	* include/experimental/internet (address_v6::to_string): Include
	scope ID in string.
	* testsuite/experimental/net/internet/address/v6/members.cc:
	Test to_string() results.
2021-02-12 15:08:29 +00:00
Jonathan Wakely
970ba71925 libstdc++: Fix errors in <experimental/internet>
libstdc++-v3/ChangeLog:

	* include/experimental/internet (address_v6::any): Avoid using
	memcpy in constexpr function.
	(address_v6::loopback): Likewise.
	(make_address_v6): Fix missing return statements on error paths.
	* include/experimental/io_context: Avoid -Wdangling-else
	warning.
	* testsuite/experimental/net/internet/address/v4/members.cc:
	Remove unused variables.
	* testsuite/experimental/net/internet/address/v6/members.cc:
	New test.
2021-02-12 14:30:14 +00:00
Jonathan Wakely
87eaa3c525 libstdc++: Add unused attributes to shared_ptr functions
This avoids some warnings when building with -fno-rtti because the
function parameters are only used when RTTI is enabled.

libstdc++-v3/ChangeLog:

	* include/bits/shared_ptr_base.h (__shared_ptr::_M_get_deleter):
	Add unused attribute to parameter.
	* src/c++11/shared_ptr.cc (_Sp_make_shared_tag::_S_eq):
	Likewise.
2021-02-12 14:30:14 +00:00
Jonathan Wakely
c4ece1d96a libstdc++: XFAIL tests that depends on RTTI
The std::emit_on_flush manipulator depends on dynamic_cast, so fails
without RTTI.

The std::async code can't catch a forced_unwind exception when RTTI is
disabled, so it can't rethrow it either, and the test aborts.

libstdc++-v3/ChangeLog:

	* testsuite/27_io/basic_ostream/emit/1.cc: Expect test to fail
	if -fno-rtti is used.
	* testsuite/30_threads/async/forced_unwind.cc: Expect test
	to abort if -fno-rtti is used.
2021-02-12 14:30:13 +00:00
Jonathan Wakely
0bd242ec5a libstdc++: Make test memory_resource work without exceptions and RTTI
libstdc++-v3/ChangeLog:

	* testsuite/util/testsuite_allocator.h (memory_resource):
	Remove requirement for RTTI and exceptions to be enabled.
2021-02-12 14:30:13 +00:00
Jonathan Wakely
e9c3105211 libstdc++: Only use dynamic_cast in tests when RTTI is enabled
libstdc++-v3/ChangeLog:

	* testsuite/27_io/basic_istringstream/rdbuf/char/2832.cc: Use
	static_cast when RTTI is disabled.
	* testsuite/27_io/basic_istringstream/rdbuf/wchar_t/2832.cc:
	Likewise.
	* testsuite/27_io/basic_ostringstream/rdbuf/char/2832.cc:
	Likewise.
	* testsuite/27_io/basic_ostringstream/rdbuf/wchar_t/2832.cc:
	Likewise.
	* testsuite/27_io/basic_stringstream/str/char/2.cc:
	Likewise.
	* testsuite/27_io/basic_stringstream/str/wchar_t/2.cc:
	Likewise.
2021-02-12 14:30:13 +00:00
Jonathan Wakely
14b554c462 libstdc++: Fix errors when syncbuf is used without RTTI
libstdc++-v3/ChangeLog:

	* include/std/ostream (__syncbuf_base::_S_get): Mark parameter
	as unused and only use dynamic_cast when RTTI is enabled.
2021-02-12 14:30:12 +00:00
Jonathan Wakely
4591f7e532 libstdc++: Fix bootstrap with -fno-rtti [PR 99077]
When libstdc++ is built without RTTI the __ios_failure type is just an
alias for std::ios_failure, so trying to construct it from an int won't
compile. This changes the RTTI-enabled __ios_failure type to have the
same constructor parameters as std::ios_failure, so that the constructor
takes the same arguments whether RTTI is enabled or not.

The __throw_ios_failure function now constructs the error_code, instead
of the __ios_failure constructor. As a drive-by fix that error_code is
constructed with std::generic_category() not std::system_category(),
because the int comes from errno which corresponds to the generic
category.

libstdc++-v3/ChangeLog:

	PR libstdc++/99077
	* src/c++11/cxx11-ios_failure.cc (__ios_failure(const char*, int)):
	Change int parameter to error_code, to match std::ios_failure.
	(__throw_ios_failure(const char*, int)): Construct error_code
	from int parameter.
2021-02-12 14:30:12 +00:00
Christophe Lyon
71b8ed7c61 testsuite, arm: Add -mthumb to pr98931.c [PR target/98931]
This test forces -march=armv8.1-m.main, which supports only Thumb mode.
However, if the toolchain is not configured --with-thumb, the test
fails with:
error: target CPU does not support ARM mode

Adding -mthumb to dg-options fixes the problem.

2021-02-12  Christophe Lyon  <christophe.lyon@linaro.org>

	PR target/98931
	gcc/testsuite/
	* gcc.target/arm/pr98931.c: Add -mthumb
2021-02-12 14:19:24 +00:00
Arnaud Charlet
3fbf81a252 [Ada] Remove unused subprograms (continued)
gcc/ada/

	* repinfo.ads, repinfo.adb (*SO_Ref*): Restore.
2021-02-12 08:53:41 -05:00
Tobias Burnus
f699e0b165 Fortran: Fix rank of assumed-rank array [PR99043]
gcc/fortran/ChangeLog:

	PR fortran/99043
	* trans-expr.c (gfc_conv_procedure_call): Don't reset
	rank of assumed-rank array.

gcc/testsuite/ChangeLog:

	PR fortran/99043
	* gfortran.dg/assumed_rank_20.f90: New test.
2021-02-12 14:43:41 +01:00
Richard Biener
6cc886bf42 middle-end/38474 - fix alias walk budget accounting in IPA analysis
The walk_aliased_vdef calls do not update the walking budget until
it is hit by a single call (and then in one case it resumes with
no limit at all).  The following rectifies this in multiple places.
It also makes the updates more consistend and fixes
determine_known_aggregate_parts to account its own alias queries.

2021-02-12  Richard Biener  <rguenther@suse.de>

	PR middle-end/38474
	* ipa-fnsummary.c (unmodified_parm_1): Only walk when
	fbi->aa_walk_budget is bigger than zero.  Update
	fbi->aa_walk_budget.
	(param_change_prob): Likewise.
	* ipa-prop.c (detect_type_change_from_memory_writes):
	Properly account walk_aliased_vdefs.
	(parm_preserved_before_stmt_p): Canonicalize updates.
	(parm_ref_data_preserved_p): Likewise.
	(parm_ref_data_pass_through_p): Likewise.
	(determine_known_aggregate_parts): Account own alias queries.
2021-02-12 12:34:28 +01:00
Martin Liska
bc6087c575 Fix producer string memory leaks
gcc/ChangeLog:

	* opts-common.c (decode_cmdline_option): Release werror_arg.
	* opts.c (gen_producer_string): Release output of
	gen_command_line_string.
2021-02-12 10:25:06 +01:00
Jakub Jelinek
cf059e1c09 c++: Fix endless errors on invalid requirement seq [PR97742]
As the testcase shows, if we reach CPP_EOF during parsing of requirement
sequence, we end up with endless loop where we always report invalid
requirement expression, don't consume any token (as we are at eof) and
repeat.

This patch stops the loop when we reach CPP_EOF.

2021-02-12  Jakub Jelinek  <jakub@redhat.com>

	PR c++/97742
	* parser.c (cp_parser_requirement_seq): Stop iterating after reaching
	CPP_EOF.

	* g++.dg/cpp2a/concepts-requires24.C: New test.
2021-02-12 09:58:25 +01:00
Richard Biener
95d94b52ea tree-optimization/38474 - fix store-merging compile-time regression
The following puts a limit on the number of alias tests we do in
terminate_all_aliasing_chains which is quadratic in the number of
overall stores currentrly tracked.  There is already a limit in
place on the maximum number of stores in a single chain so the
following adds a limit on the number of chains tracked.  The
worst number of overall stores tracked from the defaults (64 and 64)
is then 4096 which when imposed as the sole limit for the testcase
still causes

 store merging                      :  71.65 ( 56%)

because the testcase is somewhat degenerate with most chains
consisting only of a single store (and 25% of exactly three stores).
The single stores are all CLOBBERs at the point variables go out of
scope.  Note unpatched we have

 store merging                      : 308.60 ( 84%)

Limiting the number of chains to 64 brings this down to

 store merging                      :   1.52 (  3%)

which is more reasonable.  There are ideas on how to make
terminate_all_aliasing_chains cheaper but for this degenerate case
they would not have any effect so I'll defer for GCC 12 for those.

I'm not sure we want to have both --params, just keeping the
more to-the-point max-stores-to-track works but makes the
degenerate case above slower.
I made the current default 1024 which for the testcasse
(without limiting chains) results in 25% compile time and 20s
putting it in the same ballpart as the next offender (which is PTA).

This is a regression on trunk and the GCC 10 branch btw.

2021-02-11  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/38474
	* params.opt (-param=max-store-chains-to-track=): New param.
	(-param=max-stores-to-track=): Likewise.
	* doc/invoke.texi (max-store-chains-to-track): Document.
	(max-stores-to-track): Likewise.
	* gimple-ssa-store-merging.c (pass_store_merging::m_n_chains):
	New.
	(pass_store_merging::m_n_stores): Likewise.
	(pass_store_merging::terminate_and_process_chain): Update
	m_n_stores and m_n_chains.
	(pass_store_merging::process_store): Likewise.   Terminate
	oldest chains if the number of stores or chains get too large.
	(imm_store_chain_info::terminate_and_process_chain): Dump
	chain length.
2021-02-12 09:38:52 +01:00
Jason Merrill
ac001ddd0c c++: variadic lambda template and empty pack [PR97246]
In get<0>, Is is empty, so the first parameter pack of the lambda is empty,
but after the fix for PR94546 we were wrongly associating it with the
partial instantiation of 'v'.

gcc/cp/ChangeLog:

	PR c++/97246
	PR c++/94546
	* pt.c (extract_fnparm_pack): Check DECL_PACK_P here.
	(register_parameter_specializations): Not here.

gcc/testsuite/ChangeLog:

	PR c++/97246
	* g++.dg/cpp2a/lambda-generic-variadic21.C: New test.
2021-02-11 21:30:24 -05:00
Ian Lance Taylor
3e2f329e94 libbacktrace: check for objcopy --add-gnu-debuglink using --help
* configure.ac: Check for objcopy --add-gnu-debuglink by using
	objcopy --help.
	* configure: Regenerate
2021-02-11 18:10:25 -08:00
David Malcolm
467a482052 analyzer: fix ICE in print_mem_ref [PR98969]
PR analyzer/98969 and PR analyzer/99064 describes ICEs, in both cases
within print_mem_ref, when falsely reporting memory leaks - though it
is possible to generate the ICE on other diagnostics (which I added
in one of the test cases).

This patch fixes the ICE, leaving the fix for the leak false positives
as followup work.

The analyzer uses region_model::get_representative_path_var and
region_model::get_representative_tree to map back from its svalue
and region classes to the tree type used by the rest of the compiler,
and, in particular, for diagnostics.

The root cause of the ICE is sloppiness about types within those
functions; specifically when casts were stripped off svalues.  To
track these down I added wrapper functions that verify that the
types of the results are correct, and in doing so found various
other type-safety issues, which the patch also fixes.

Doing so led to various changes in diagnostics messages due to
more accurate types, but I felt that these changes weren't
desirable.
For example, the warning at CVE-2005-1689-minimal.c line 48
which expects:
  double-'free' of 'inbuf.data'
changed fo
  double-'free' of '(char *)inbuf.data'

So I added stripping of top-level casts where necessary to avoid
cluttering diagnostics.

Finally, the more accurate types led to worse results from
readability_comparator, where e.g. the event message at line 50
of sensitive-1.c regressed from the precise:
  passing sensitive value 'password' in call to 'called_by_test_5' from 'test_5'
to the vaguer:
  calling 'called_by_test_5' from 'test_5'
This was due to erroneously picking the initial value of "password"
in the caller frame as the best value within the *callee* frame, due to
"char *" vs "const char *", which confuses the logic for tracking values
that pass along callgraph edges.  The patch fixes this by combining the
readability tests for tree and stack depth, rather than performing
them in sequence, so that it favors the value in the deepest frame.

As noted above, the patch fixes the ICEs, but does not fix the
leak false positives.

gcc/analyzer/ChangeLog:
	PR analyzer/98969
	* engine.cc (readability): Add names for the various arbitrary
	values.  Handle NOP_EXPR and INTEGER_CST.
	(readability_comparator): Combine the readability tests for
	tree and stack depth, rather than performing them sequentially.
	(impl_region_model_context::on_state_leak): Strip off top-level
	casts.
	* region-model.cc (region_model::get_representative_path_var): Add
	type-checking, moving the bulk of the implementation to...
	(region_model::get_representative_path_var_1): ...here.  Respect
	types in casts by recursing and re-adding the cast, rather than
	merely stripping them off.  Use the correct type when handling
	region_svalue.
	(region_model::get_representative_tree): Strip off any top-level
	cast.
	(region_model::get_representative_path_var): Add type-checking,
	moving the bulk of the implementation to...
	(region_model::get_representative_path_var_1): ...here.
	* region-model.h (region_model::get_representative_path_var_1):
	New decl
	(region_model::get_representative_path_var_1): New decl.
	* store.cc (append_pathvar_with_type): New.
	(binding_cluster::get_representative_path_vars): Cast path_vars
	to the correct type when adding them to *OUT_PVS.

gcc/testsuite/ChangeLog:
	PR analyzer/98969
	* g++.dg/analyzer/pr99064.C: New test.
	* gcc.dg/analyzer/pr98969.c: New test.
2021-02-11 20:32:10 -05:00
GCC Administrator
0c5cdb31bd Daily bump. 2021-02-12 00:16:25 +00:00
Eric Botcazou
85cefe2256 Fix -freorder-blocks-and-partition glitch with Windows SEH
Since GCC 8, the -freorder-blocks-and-partition pass can split a function
into hot and cold parts, thus generating 2 CIEs for a single function in
DWARF for exception purposes and doing an equivalent trick for Windows SEH.

Now the Windows system unwinder is picky when it comes to the boundary
between an active EH region and the end of the function and, therefore,
a nop may need to be added in specific cases.

gcc/
	* config/i386/winnt.c (i386_pe_seh_unwind_emit): When switching to
	the cold section, emit a nop before the directive if the previous
	active instruction can throw.
2021-02-12 00:19:21 +01:00
Uros Bizjak
5e40542f87 libgomp/i386: Revert the type of syscall wrappers output back to long.
Linux man-pages 5.07 wrongly declares syscall output type as int.  This error
was fixed in release 5.10, so this patch reverts my recent change.

2021-02-11  Uroš Bizjak  <ubizjak@gmail.com>

libgomp/
	* config/linux/x86/futex.h (__futex_wait):
	Revert output type back to long.
	(__futex_wake): Ditto.
	(futex_wait): Update for revert.
	(futex_wake): Ditto.
2021-02-12 00:07:56 +01:00
Uros Bizjak
c36ad24e8a libgomp/i386: Move syscall asms to static inline wrapper.
Move syscall asms to static inline wrapper functions to improve #ifdeffery.
Also correct output type to int and timeout type to void *.

2021-02-11  Uroš Bizjak  <ubizjak@gmail.com>

libgomp/
	* config/linux/x86/futex.h (__futex_wait): New static inline
	wrapper function.  Correct output type to int and
	timeout type to void *.
	(__futex_wake): New static inline wrapper function.
	Correct output type to int.
	(futex_wait): Use __futex_wait.
	(futex_wake): Use __futex_wake.
2021-02-11 22:49:41 +01:00
Marek Polacek
88cfd531c6 c++: Endless loop with targ deduction in member tmpl [PR95888]
My r10-7007 patch tweaked tsubst not to reduce the template level of
template parameters when tf_partial.  That caused infinite looping in
is_specialization_of: we ended up with a class template specialization
whose TREE_TYPE (CLASSTYPE_TI_TEMPLATE (t)) == t, so the second for
loop in is_specialization_of never finished.

There's a lot going on in this test, but essentially: the template fn
here has two template parameters, we call it with one explicitly
provided, the other one has to be deduced.  So we'll find ourselves
in fn_type_unification which uses tf_partial when tsubsting the
*explicit* template arguments into the function type.  That leads to
tsubstituting the return type, C<T>.  C is a member template; its
most general template is

  template<class U> template<class V> struct B<U>::C

we figure out (tsubst_template_args) that the template argument list
is <int, int>.  They come from different levels, one comes from B<int>,
the other one from fn<int>.

So now we lookup_template_class to see if we have C<int, int>.  We
do the
  /* This is a full instantiation of a member template.  Find
     the partial instantiation of which this is an instance.  */
  TREE_VEC_LENGTH (arglist)--;
  // arglist is now <int>, not <int, int>
  found = tsubst (gen_tmpl, arglist, complain, NULL_TREE);
  TREE_VEC_LENGTH (arglist)++;

magic which is looking for the partial instantiation, in this case,
that would be template<class V> struct B<int>::C.  Note we're still
in a tf_partial context!  So the tsubst_template_args in the tsubst
(which tries to substitute <int> into <U, V>) returns <int, V>, but
V's template level hasn't been reduced!  After tsubst_template_args,
tsubst_template_decl looks to see if we already have this specialization:

  // t = template_decl C
  // full_args = <int, V>
  spec = retrieve_specialization (t, full_args, hash);

but doesn't find the one we created a while ago, when processing
B<int> b; in the test, because V's levels don't match.  Whereupon
tsubst_template_decl creates a new TEMPLATE_DECL, one that leads to
the infinite looping problem.

Fixed by using tf_none when looking for an existing partial instantiation.

It also occurred to me that I should be able to trigger a similar
problem with 'auto', since r10-7007 removed an is_auto check.  And lo,
I constructed deduce10.C which exhibits the same issue with pre-r10-7007
compilers.  This patch fixes that problem as well.  I'm ecstatic.

gcc/cp/ChangeLog:

	PR c++/95888
	* pt.c (lookup_template_class_1): Pass tf_none to tsubst when looking
	for the partial instantiation.

gcc/testsuite/ChangeLog:

	PR c++/95888
	* g++.dg/template/deduce10.C: New test.
	* g++.dg/template/deduce9.C: New test.
2021-02-11 15:56:04 -05:00
Peter Bergner
2432c47970 rs6000: Fix invalid address used in MMA built-in function
The mma_assemble_input_operand predicate is too lenient on the memory
operands it will accept, leading to an ICE when illegitimate addresses
are passed in.  The solution is to only accept memory operands with
addresses that are valid for quad word memory accesses.  The test case
is a minimized test case from the Eigen library.  The creduced test case
is very noisy with respect to warnings, so the test case has added -w to
silence them.

2021-02-11  Peter Bergner  <bergner@linux.ibm.com>

gcc/
	PR target/99041
	* config/rs6000/predicates.md (mma_assemble_input_operand): Restrict
	memory addresses that are legal for quad word accesses.

gcc/testsuite/
	PR target/99041
	* g++.target/powerpc/pr99041.C: New test.
2021-02-11 14:16:05 -06:00
Jonathan Wakely
bc0f7db7eb libstdc++: Fix versioned namespace build
The recent changes to define various std::exception_ptr functions inline
included a change so that the definitions of those functions would be
omitted for the ABI unstable gnu-versioned-namespace configuration. That
change was incorrect, because the existing functions that are gated by
the _GLIBCXX_EH_PTR_COMPAT macro are always needed even for the
versioned namespace.

This change introduces a new macro to control whether operator== is
defined as deleted or not, distinct from the existing macro. The new
macro is not defined for versioned namespace builds, but the old macro
still is.

libstdc++-v3/ChangeLog:

	* libsupc++/eh_ptr.cc (_GLIBCXX_EH_PTR_RELOPS_COMPAT): Define
	new macro.
	* libsupc++/exception_ptr.h (_GLIBCXX_EH_PTR_USED): Check new
	macro instead of _GLIBCXX_EH_PTR_COMPAT.
	(operator==): Likewise.
2021-02-11 17:28:16 +00:00
Jonathan Wakely
ce43c90604 libstdc++: Document when C++11/14/17 support became stable [PR 99058]
libstdc++-v3/ChangeLog:

	PR libstdc++/99058
	* doc/xml/manual/status_cxx2011.xml: Document when support
	became stable.
	* doc/xml/manual/status_cxx2014.xml: Likewise.
	* doc/xml/manual/status_cxx2017.xml: Likewise.
	* doc/html/manual/status.html: Regenerate.
2021-02-11 17:28:16 +00:00
Jakub Jelinek
2dcdd15d0b c++: Fix zero initialization of flexible array members [PR99033]
array_type_nelts returns error_mark_node for type of flexible array members
and build_zero_init_1 was placing an error_mark_node into the CONSTRUCTOR,
on which e.g. varasm ICEs.  I think there is nothing erroneous on zero
initialization of flexible array members though, such arrays should simply
get no elements, like they do if such classes are constructed (everything
except when some larger initializer comes from an explicit initializer).

So, this patch handles [] arrays in zero initialization like [0] arrays
and fixes handling of the [0] arrays - the
tree_int_cst_equal (max_index, integer_minus_one_node) check
didn't do what it thought it would do, max_index is typically unsigned
integer (sizetype) and so it is never equal to a -1.

What the patch doesn't do and maybe would be desirable is if it returns
error_mark_node for other reasons let the recursive callers not stick that
into CONSTRUCTOR but return error_mark_node instead.  But I don't have a
testcase where that would be needed right now.

2021-02-11  Jakub Jelinek  <jakub@redhat.com>

	PR c++/99033
	* init.c (build_zero_init_1): Handle zero initialiation of
	flexible array members like initialization of [0] arrays.
	Use integer_minus_onep instead of comparison to integer_minus_one_node
	and integer_zerop instead of comparison against size_zero_node.
	Formatting fixes.

	* g++.dg/ext/flexary38.C: New test.
2021-02-11 17:24:17 +01:00
Marek Polacek
f0da1c0cb7 c++: ICE with unexpanded pack in do-while [PR99063]
Here an unexpanded parameter pack snuck into prep_operand which doesn't
expect to see an operand without a type, and since r247842
NONTYPE_ARGUMENT_PACK doesn't have a type anymore.

This only happens with the do-while loop whose condition may not
contain a declaration so we never called finish_cond which checks
for unexpanded parameter packs.  So use check_for_bare_parameter_packs
to remedy that.

gcc/cp/ChangeLog:

	PR c++/99063
	* semantics.c (finish_do_stmt): Check for unexpanded parameter packs.

gcc/testsuite/ChangeLog:

	PR c++/99063
	* g++.dg/cpp0x/variadic-crash6.C: New test.
2021-02-11 11:12:49 -05:00