181913 Commits

Author SHA1 Message Date
Matt Thomas
a27d5f9a73 PR target/58901: reload: Handle SUBREG of MEM with a mode-dependent address
Fix an ICE with the handling of RTL expressions like:

(subreg:QI (mem/c:SI (plus:SI (plus:SI (mult:SI (reg/v:SI 0 %r0 [orig:67 i ] [67])
                    (const_int 4 [0x4]))
                (reg/v/f:SI 7 %r7 [orig:59 doacross ] [59]))
            (const_int 40 [0x28])) [1 MEM[(unsigned int *)doacross_63 + 40B + i_106 * 4]+0 S4 A32]) 0)

that causes the compilation of libgomp to fail:

during RTL pass: reload
.../libgomp/ordered.c: In function 'GOMP_doacross_wait':
.../libgomp/ordered.c:507:1: internal compiler error: in change_address_1, at emit-rtl.c:2275
  507 | }
      | ^
0x10a3462b change_address_1
	.../gcc/emit-rtl.c:2275
0x10a353a7 adjust_address_1(rtx_def*, machine_mode, poly_int<1u, long>, int, int, int, poly_int<1u, long>)
	.../gcc/emit-rtl.c:2409
0x10ae2993 alter_subreg(rtx_def**, bool)
	.../gcc/final.c:3368
0x10ae25cf cleanup_subreg_operands(rtx_insn*)
	.../gcc/final.c:3322
0x110922a3 reload(rtx_insn*, int)
	.../gcc/reload1.c:1232
0x10de2bf7 do_reload
	.../gcc/ira.c:5812
0x10de3377 execute
	.../gcc/ira.c:5986

in a `vax-netbsdelf' build, where an attempt is made to change the mode
of the contained memory reference to the mode of the containing SUBREG.
Such RTL expressions are produced by the VAX shift and rotate patterns
(`ashift', `ashiftrt', `rotate', `rotatert') where the count operand
always has the QI mode regardless of the mode, either SI or DI, of the
datum shifted or rotated.

Such a mode change cannot work where the memory reference uses the
indexed addressing mode, where a multiplier is implied that in the VAX
ISA depends on the width of the memory access requested and therefore
changing the machine mode would change the address calculation as well.

Avoid the attempt then by forcing the reload of any SUBREGs containing
a mode-dependent memory reference, also fixing these regressions:

FAIL: gcc.c-torture/compile/pr46883.c   -Os  (internal compiler error)
FAIL: gcc.c-torture/compile/pr46883.c   -Os  (test for excess errors)
FAIL: gcc.c-torture/execute/20120808-1.c   -O2  (internal compiler error)
FAIL: gcc.c-torture/execute/20120808-1.c   -O2  (test for excess errors)
FAIL: gcc.c-torture/execute/20120808-1.c   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  (internal compiler error)
FAIL: gcc.c-torture/execute/20120808-1.c   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  (test for excess errors)
FAIL: gcc.c-torture/execute/20120808-1.c   -O3 -g  (internal compiler error)
FAIL: gcc.c-torture/execute/20120808-1.c   -O3 -g  (test for excess errors)
FAIL: gcc.c-torture/execute/20120808-1.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  (internal compiler error)
FAIL: gcc.c-torture/execute/20120808-1.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  (test for excess errors)
FAIL: gcc.c-torture/execute/20120808-1.c   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  (internal compiler error)
FAIL: gcc.c-torture/execute/20120808-1.c   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  (test for excess errors)
FAIL: gcc.dg/20050629-1.c (internal compiler error)
FAIL: gcc.dg/20050629-1.c (test for excess errors)
FAIL: c-c++-common/torture/pr53505.c   -Os  (internal compiler error)
FAIL: c-c++-common/torture/pr53505.c   -Os  (test for excess errors)
FAIL: gfortran.dg/coarray_failed_images_1.f08   -Os  (internal compiler error)
FAIL: gfortran.dg/coarray_stopped_images_1.f08   -Os  (internal compiler error)

With test case #0 included it causes a reload with:

(insn 15 14 16 4 (set (reg:SI 31)
        (ashift:SI (const_int 1 [0x1])
            (subreg:QI (reg:SI 30 [ MEM[(int *)s_8(D) + 4B + _5 * 4] ]) 0))) "pr58901-0.c":15:12 94 {ashlsi3}
     (expr_list:REG_DEAD (reg:SI 30 [ MEM[(int *)s_8(D) + 4B + _5 * 4] ])
        (nil)))

as follows:

Reloads for insn # 15
Reload 0: reload_in (SI) = (reg:SI 30 [ MEM[(int *)s_8(D) + 4B + _5 * 4] ])
	ALL_REGS, RELOAD_FOR_INPUT (opnum = 2)
	reload_in_reg: (reg:SI 30 [ MEM[(int *)s_8(D) + 4B + _5 * 4] ])
	reload_reg_rtx: (reg:SI 5 %r5)

resulting in:

(insn 37 14 15 4 (set (reg:SI 5 %r5)
        (mem/c:SI (plus:SI (plus:SI (mult:SI (reg/v:SI 1 %r1 [orig:25 i ] [25])
                        (const_int 4 [0x4]))
                    (reg/v/f:SI 4 %r4 [orig:29 s ] [29]))
                (const_int 4 [0x4])) [1 MEM[(int *)s_8(D) + 4B + _5 * 4]+0 S4 A32])) "pr58901-0.c":15:12 12 {movsi_2}
     (nil))
(insn 15 37 16 4 (set (reg:SI 2 %r2 [31])
        (ashift:SI (const_int 1 [0x1])
            (reg:QI 5 %r5))) "pr58901-0.c":15:12 94 {ashlsi3}
     (nil))

and assembly like:

.L3:
	movl 4(%r4)[%r1],%r5
	ashl %r5,$1,%r2
	xorl2 %r2,%r0
	incl %r1
	cmpl %r1,%r3
	jneq .L3

produced for the loop, providing optimization has been enabled.

Likewise with test case #1 the reload of:

(insn 17 16 18 4 (set (reg:SI 34)
        (and:SI (subreg:SI (reg/v:DI 27 [ t ]) 4)
            (const_int 1 [0x1]))) "pr58901-1.c":18:20 77 {*andsi_const_int}
     (expr_list:REG_DEAD (reg/v:DI 27 [ t ])
        (nil)))

is as follows:

Reloads for insn # 17
Reload 0: reload_in (DI) = (reg/v:DI 27 [ t ])
	reload_out (SI) = (reg:SI 2 %r2 [34])
	ALL_REGS, RELOAD_OTHER (opnum = 0)
	reload_in_reg: (reg/v:DI 27 [ t ])
	reload_out_reg: (reg:SI 2 %r2 [34])
	reload_reg_rtx: (reg:DI 4 %r4)

resulting in:

(insn 40 16 17 4 (set (reg:DI 4 %r4)
        (mem/c:DI (plus:SI (mult:SI (reg/v:SI 1 %r1 [orig:26 i ] [26])
                    (const_int 8 [0x8]))
                (reg/v/f:SI 3 %r3 [orig:30 s ] [30])) [1 MEM[(const struct s *)s_13(D) + _7 * 8]+0 S8 A32])) "pr58901-1.c":18:20 11 {movdi}
     (nil))
(insn 17 40 41 4 (set (reg:SI 4 %r4)
        (and:SI (reg:SI 5 %r5 [+4 ])
            (const_int 1 [0x1]))) "pr58901-1.c":18:20 77 {*andsi_const_int}
     (nil))

and assembly like:

.L3:
	movq (%r3)[%r1],%r4
	bicl3 $-2,%r5,%r4
	addl2 %r4,%r0
	jaoblss %r0,%r1,.L3

First posted at: <https://gcc.gnu.org/ml/gcc/2014-06/msg00060.html>.

2020-12-05  Matt Thomas  <matt@3am-software.com>
	    Maciej W. Rozycki  <macro@linux-mips.org>

	gcc/
	PR target/58901
	* reload.c (push_reload): Also reload the inner expression of a
	SUBREG for pseudos associated with a mode-dependent memory
	reference.
	(find_reloads): Force a reload likewise.

2020-12-05  Maciej W. Rozycki  <macro@linux-mips.org>

	gcc/testsuite/
	PR target/58901
	* gcc.c-torture/compile/pr58901-0.c: New test.
	* gcc.c-torture/compile/pr58901-1.c: New test.
2020-12-05 18:26:23 +00:00
Roman Zhuykov
4eb8f93d02 modulo-sched: Carefully process loop counter initialization [PR97421]
Do not allow direct adjustment of pre-header initialization instruction for
count register if is read in some instruction below in that basic block.

gcc/ChangeLog:

	PR rtl-optimization/97421
	* modulo-sched.c (generate_prolog_epilog): Remove forward
	declaration, adjust last argument name and type.
	(const_iteration_count): Add bool pointer parameter to return
	whether count register is read in pre-header after its
	initialization.
	(sms_schedule): Fix count register initialization adjustment
	procedure according to what const_iteration_count said.

gcc/testsuite/ChangeLog:

	PR rtl-optimization/97421
	* gcc.c-torture/execute/pr97421-1.c: New test.
	* gcc.c-torture/execute/pr97421-2.c: New test.
	* gcc.c-torture/execute/pr97421-3.c: New test.
2020-12-05 18:45:27 +03:00
Paul Thomas
7ae210d5db Fortran: flag formal argument before resolving an array spec [PR98016].
2020-12-05  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/98016
	* resolve.c (resolve_symbol): Set formal_arg_flag before
	resolving an array spec and restore value afterwards.

gcc/testsuite/
	PR fortran/98016
	* gfortran.dg/pr98016.f90: New test.
2020-12-05 14:14:19 +00:00
Iain Sandoe
1352bc88a0 Darwin : Update libtool and dependencies for Darwin20 [PR97865]
The change in major version (and the increment from Darwin19 to 20)
caused libtool tests to fail which resulted in incorrect build settings
for shared libraries.

We take this opportunity to sort out the shared undefined symbols state
rather than propagating the current unsound behaviour into a new rev.

This change means that we default to the case that missing symbols are
considered an error, and if one wants to allow this intentionally, the
confiuration for that case should be set appropriately.

Three existing cases need undefined dynamic lookup:
 libitm, where there is already a configuration mechanism to add the
         flags.
 libcc1, where we add simple configuration to add the flags for Darwin.
 libsanitizer, where we can add to the existing extra flags.

libcc1/ChangeLog:

	PR target/97865
	* Makefile.am: Add dynamic_lookup to LD flags for Darwin.
	* configure.ac: Test for Darwin host and set a flag.
	* Makefile.in: Regenerate.
	* configure: Regenerate.

libitm/ChangeLog:

	PR target/97865
	* configure.tgt: Add dynamic_lookup to XLDFLAGS for Darwin.
	* configure: Regenerate.

libsanitizer/ChangeLog:

	PR target/97865
	* configure.tgt: Add dynamic_lookup to EXTRA_CXXFLAGS for
	Darwin.
	* configure: Regenerate.

ChangeLog:

	PR target/97865
	* libtool.m4: Update handling of Darwin platform link flags
	for Darwin20.

gcc/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libatomic/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libbacktrace/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libffi/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libgfortran/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libgomp/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libhsail-rt/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libobjc/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libphobos/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libquadmath/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libssp/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libstdc++-v3/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libvtv/ChangeLog:

	PR target/97865
	* configure: Regenerate.

zlib/ChangeLog:

	PR target/97865
	* configure: Regenerate.
2020-12-05 08:43:20 +00:00
Venkataramanan Kumar
3e2ae3ee28 X86_64: Enable support for next generation AMD Zen3 CPU.
2020-12-03  Venkataramanan Kumar  <Venkataramanan.Kumar@amd.com>
	    Sharavan Kumar  <Shravan.Kumar@amd.com>

gcc/ChangeLog:

	* common/config/i386/cpuinfo.h (get_amd_cpu) recognize znver3.
	* common/config/i386/i386-common.c (processor_names): Add
	znver3.
	(processor_alias_table): Add znver3 and AMDFAM19H entry.
	* common/config/i386/i386-cpuinfo.h (processor_types): Add
	AMDFAM19H.
	(processor_subtypes): AMDFAM19H_ZNVER3.
	* config.gcc (i[34567]86-*-linux* | ...): Likewise.
	* config/i386/driver-i386.c: (host_detect_local_cpu): Let
	-march=native recognize znver3 processors.
	* config/i386/i386-c.c (ix86_target_macros_internal): Add
	znver3.
	* config/i386/i386-options.c (m_znver3): New definition.
	(m_ZNVER): Include m_znver3.
	(processor_cost_table): Add znver3.
	* config/i386/i386.c (ix86_reassociation_width): Likewise.
	* config/i386/i386.h (TARGET_znver3): New definition.
	(enum processor_type): Add PROCESSOR_ZNVER3.
	* config/i386/i386.md (define_attr "cpu"): Add znver3.
	* config/i386/x86-tune-sched.c: (ix86_issue_rate): Likewise.
	(ix86_adjust_cost): Likewise.
	* config/i386/x86-tune.def (X86_TUNE_AVOID_256FMA_CHAINS:
	Likewise.
	* config/i386/znver1.md: Add new reservations for znver3.
	* doc/extend.texi: Add details about znver3.
	* doc/invoke.texi: Likewise.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/funcspec-56.inc: Handle new march.
	* g++.target/i386/mv29.C: New file.
2020-12-05 11:19:35 +05:30
Jakub Jelinek
625e002396 i386: Combine splitters followup [PR96226]
Here is the patch to simplify the newly added combine splitters,
when we split into 2 insns anyway, no reason to split into the masking
define_insn_and_split we'd be splitting shortly after.

2020-12-05  Jakub Jelinek  <jakub@redhat.com>

	PR target/96226
	* config/i386/i386.md (splitter after *<rotate_insn><mode>3_mask,
	splitter after *<rotate_insn><mode>3_mask_1): Drop the masking from
	the patterns to split into.
2020-12-05 01:31:08 +01:00
Jakub Jelinek
43e84ce7d6 c++: Fix constexpr access to union member through pointer-to-member [PR98122]
We currently incorrectly reject the first testcase, because
cxx_fold_indirect_ref_1 doesn't attempt to handle UNION_TYPEs.
As the second testcase shows, it isn't that easy, because I believe we need
to take into account the active member and prefer that active member over
other members, because if we pick a non-active one, we might reject valid
programs.

2020-12-05  Jakub Jelinek  <jakub@redhat.com>

	PR c++/98122
	* constexpr.c (cxx_union_active_member): New function.
	(cxx_fold_indirect_ref_1): Add ctx argument, pass it through to
	recursive call.  Handle UNION_TYPE.
	(cxx_fold_indirect_ref): Add ctx argument, pass it to recursive calls
	and cxx_fold_indirect_ref_1.
	(cxx_eval_indirect_ref): Adjust cxx_fold_indirect_ref calls.

	* g++.dg/cpp1y/constexpr-98122.C: New test.
	* g++.dg/cpp2a/constexpr-98122.C: New test.
2020-12-05 01:30:08 +01:00
GCC Administrator
c5fd8a9157 Daily bump. 2020-12-05 00:16:39 +00:00
Ian Lance Taylor
918a5b84a2 runtime: update type descriptor name in fieldtrack C support code
We were using the old name, but nothing noticed because it is a weak
reference that is permitted to be nil, so that it works with code that
does not use the field tracking library.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/275449
2020-12-04 14:51:09 -08:00
Jason Merrill
a95753214b c++: Fix deduction from auto template parameter [PR93083]
The check in do_class_deduction to handle passing one class placeholder
template parm as an argument for itself needed to be extended to also handle
equivalent parms from other templates.

gcc/cp/ChangeLog:

	PR c++/93083
	* pt.c (convert_template_argument): Handle equivalent placeholders.
	(do_class_deduction): Look through EXPR_PACK_EXPANSION, too.

gcc/testsuite/ChangeLog:

	PR c++/93083
	* g++.dg/cpp2a/nontype-class40.C: New test.
2020-12-04 17:47:05 -05:00
Jason Merrill
df933e307b vec: Simplify use with C++11 range-based 'for'.
It looks cleaner if we can use a vec* directly as a range for the C++11
range-based 'for' loop, without needing to indirect from it, and also works
with null pointers.

The change in cp_parser_late_parsing_default_args is an example of how this
can be used to simplify a simple loop over a vector.  Reverse or subset
iteration will require adding range adaptors.

I deliberately didn't format the new overloads for etags since they are
trivial.

gcc/ChangeLog:

	* vec.h (begin, end): Add overloads for vec*.
	* tree.c (build_constructor_from_vec): Remove *.

gcc/cp/ChangeLog:

	* decl2.c (clear_consteval_vfns): Remove *.
	* pt.c (do_auto_deduction): Remove *.
	* parser.c (cp_parser_late_parsing_default_args): Change loop
	to use range 'for'.
2020-12-04 14:45:25 -05:00
David Edelsohn
b96802994a rs6000: fix PTR_SIZE in rs6000.c
The recent change to rs6000.c for DWARF in AIX references the macro
PTR_SIZE that only is defined in dwarf2out.c.  This patch changes the
reference to the equivalent POINTER_SIZE_UNITS defined in defaults.h.

gcc/ChangeLog:

	* config/rs6000/rs6000.c (rs6000_option_override_internal):
	Change PTR_SIZE to POINTER_SIZE_UNITS.
2020-12-04 14:33:06 -05:00
Hans-Peter Nilsson
eb79f4db49 doc/implement-c.texi: About same-as-scalar-type volatile aggregate accesses, PR94600
We say very little about reads and writes to aggregate /
compound objects, just scalar objects (i.e. assignments don't
cause reads).  Let's lets say something safe about aggregate
objects, but only for those that are the same size as a scalar
type.

There's an equal-sounding section (Volatiles) in extend.texi,
but this seems a more appropriate place, as specifying the
behavior of a standard qualifier.

gcc:

2020-12-04  Hans-Peter Nilsson  <hp@axis.com>
	    Martin Sebor  <msebor@redhat.com>

	PR middle-end/94600
	* doc/implement-c.texi (Qualifiers implementation): Add blurb
	about access to the whole of a volatile aggregate object, only for
	same-size as a scalar object.
2020-12-04 20:29:27 +01:00
Jakub Jelinek
78c4a9fece gimple: Return fnspec only for replaceable new/delete operators called from new/delete [PR98130]
As mentioned in the PR, we shouldn't treat non-replaceable operator
new/delete (e.g. with the placement new) as replaceable ones.

There is some pending discussion that perhaps operator delete called from
delete if not replaceable should return some other fnspec, but can we handle
that incrementally, fix this wrong-code and then deal with a missed
optimization?  I really don't know what exactly should be returned.

2020-12-04  Jakub Jelinek  <jakub@redhat.com>

	PR c++/98130
	* gimple.c (gimple_call_fnspec): Only return ".co " for replaceable
	operator delete or ".mC" for replaceable operator new called from
	new/delete.

	* g++.dg/opt/pr98130.C: New test.
2020-12-04 19:10:56 +01:00
Jakub Jelinek
ac2a6962b9 i386: Add combine splitters to allow combining multiple insns into reg1 = const; reg2 = rotate (reg1, reg3 & cst) [PR96226]
As mentioned in the PR, we can combine ~(1 << x) into -2 r<< x, but we give
up in the ~(1 << (x & 31)) cases, as *<rotate_insn><mode>3_mask* don't allow
immediate operand 1 and find_split_point prefers to split (x & 31) instead
of the constant.

With these combine splitters we help combine decide how to split those
insns.

2020-12-04  Jakub Jelinek  <jakub@redhat.com>

	PR target/96226
	* config/i386/i386.md (splitter after *<rotate_insn><mode>3_mask,
	splitter after *<rotate_insn><mode>3_mask_1): New combine splitters.

	* gcc.target/i386/pr96226.c: New test.
2020-12-04 18:44:31 +01:00
Jakub Jelinek
33be07be9e fold-const: Don't use build_constructor for non-aggregate types in native_encode_initializer [PR93121]
The following testcase is rejected, because when trying to encode a zeroing
CONSTRUCTOR, the code was using build_constructor to build initializers for
the elements but when recursing the function handles CONSTRUCTOR only for
aggregate types.

The following patch fixes that by using build_zero_cst instead for
non-aggregates.  Another option would be add handling CONSTRUCTOR for
non-aggregates in native_encode_initializer.  Or we can do both, I guess
the middle-end generally doesn't like CONSTRUCTORs for scalar variables, but
am not 100% sure if the FE doesn't produce those sometimes.

2020-12-04  Jakub Jelinek  <jakub@redhat.com>

	PR libstdc++/93121
	* fold-const.c (native_encode_initializer): Use build_zero_cst
	instead of build_constructor.

	* g++.dg/cpp2a/bit-cast6.C: New test.
2020-12-04 18:02:10 +01:00
Nathan Sidwell
5a26d4a204 c++: Revert dependent-array changes [PR 98116]
The changes reverted here are exposing an existing problem with alias
template comparisons.  The typename_type changes are also incomplete,
possibly for similar reasons.  It seems safer to revert them, fix the
underlying issue and then move forwards.

The testcases is adjusted to more robustly check the specialization
table, and ICEs with and without the c++ changes.

Revert:
62fb1b9e0da c++: Fix array type dependency [PR 98107]
07589ca2b2c c++: typename_type structural comparison
29ae1d7751 c++: Extend build_array_type API

	PR c++/98116
	gcc/cp/
	* cp-tree.h (comparing_typenames): Delete.
	(cplus_build_array_type): Remove default parm.
	* pt.c (comparing_typenames): Delete.
	(spec_hasher::equal): Don't increment it.
	* tree.c (set_array_type_canon): Remove dep parm.
	(build_cplus_array_type): Remove dep parm changes.
	(cp_build_qualified_type_real): Remove dependent array type
	changes.
	(strip_typedefs): Likewise.
	* typeck.c (structural_comptypes): Revert comparing_typename
	changes.
	gcc/testsuite/
	* g++.dg/template/pr98116.C: Enable robust checking.
2020-12-04 08:38:57 -08:00
Nathan Sidwell
97eaf8c92f c++: Module API declarations
This provides the inline predicates about module state, and declares
the functions to be provided.

	gcc/cp/
	* cp-tree.h: Add various inline module state predicates, and
	declare the API that will be provided by modules.cc
2020-12-04 05:23:22 -08:00
Jakub Jelinek
704ccefb57 debug: Fix another vector DECL_MODE ICE [PR98100]
The PR88587 fix changes DECL_MODE of vars with vector type during inlining/cloning
when the vars are copied, so that their DECL_MODE matches their TYPE_MODE in
the new function.  Unfortunately, the following testcase still ICEs, the var
isn't really used in the new function and so it isn't copied, but becomes
just a nonlocalized var.  So we can't adjust its DECL_MODE because it
appears in multiple functions and needs different modes in between them.
The following patch changes the DEBUG_INSN creation to use TYPE_MODE instead
of DECL_MODE for vars with vector types.

2020-12-04  Jakub Jelinek  <jakub@redhat.com>

	PR target/98100
	* cfgexpand.c (expand_gimple_basic_block): For vars with
	vector type, use TYPE_MODE rather than DECL_MODE.

	* gcc.target/i386/pr98100.c: New test.
2020-12-04 12:18:21 +01:00
Jakub Jelinek
65312dfc64 dwarf: Add -gdwarf{32,64} options
The following patch makes the choice between 32-bit and 64-bit DWARF formats
selectable by command line switch, rather than being hardcoded through
DWARF_OFFSET_SIZE macro.

The options themselves don't turn on debug info themselves, so one needs
to use -g -gdwarf64 or similar.

2020-12-04  Jakub Jelinek  <jakub@redhat.com>

	* common.opt (-gdwarf32, -gdwarf64): New options.
	* config/rs6000/rs6000.c (rs6000_option_override_internal): Default
	dwarf_offset_size to 8 if not overridden from the command line.
	* dwarf2out.c: Change all occurrences of DWARF_OFFSET_SIZE to
	dwarf_offset_size.
	* doc/invoke.texi (-gdwarf32, -gdwarf64): Document.
2020-12-04 10:54:45 +01:00
Martin Liska
485b40a527 testsuite: use param for if-to-switch tests
gcc/testsuite/ChangeLog:

	PR testsuite/98123
	* gcc.dg/tree-ssa/if-to-switch-4.c: Add param to make the test
	stable on all architectures.
	* gcc.dg/tree-ssa/if-to-switch-6.c: Likewise.
	* gcc.dg/tree-ssa/if-to-switch-8.c: Likewise.
2020-12-04 10:45:22 +01:00
Eric Botcazou
53a0eb0b7d Add target selector to gcc.dg/pr98099.c
gcc/testsuite/ChangeLog:
	* gcc.dg/pr98099.c: Compile only for dfp targets.
2020-12-04 10:28:43 +01:00
Martin Liska
7caa497063 Refactor -frecord-gcc-switches.
gcc/ChangeLog:

	* doc/tm.texi: Change argument of the record_gcc_switches
	hook and remove SWITCH_TYPE_* enum values.
	* dwarf2out.c (gen_producer_string): Move to opts.c and remove
	handling of the dwarf_record_gcc_switches option.
	(dwarf2out_early_finish): Use moved gen_producer_string
	function.
	* opts.c (gen_producer_string): New.
	* opts.h (gen_producer_string): New.
	* target.def: Change type of record_gcc_switches.
	* target.h (enum print_switch_type): Remove.
	(elf_record_gcc_switches): Change first argument.
	* toplev.c (MAX_LINE): Remove.
	(print_to_asm_out_file):  Likewise.
	(print_to_stderr): Likewise.
	(print_single_switch): Likewise.
	(print_switch_values): Likewise.
	(init_asm_output): Use new gen_producer_string function.
	(process_options): Likewise.
	* varasm.c (elf_record_gcc_switches): Just save the string argument
	to the ELF container.
2020-12-04 10:13:51 +01:00
Eric Botcazou
241a2c4980 Fix checking failure in IPA-SRA
This is a regression present on the mainline and 10 branch: on the one
hand, IPA-SRA does *not* disqualify accesses with zero size but, on the
other hand, it checks that accesses present in the tree have a (strictly)
positive size, thus trivially yielding an ICE in some cases.

gcc/ChangeLog:
	* ipa-sra.c (verify_access_tree_1): Relax assertion on the size.

gcc/testsuite/ChangeLog:
	* gnat.dg/opt91.ads, gnat.dg/opt91.adb: New test.
	* gnat.dg/opt91_pkg.ads, gnat.dg/opt91_pkg.adb: New helper.
2020-12-04 10:07:42 +01:00
Martin Liska
9199da4b59 Document missing params.
contrib/ChangeLog:

	* check-params-in-docs.py: use flake8 and add some
	tweaks to ignore aarch64 params.

gcc/ChangeLog:

	* doc/invoke.texi: Add missing params.
2020-12-04 09:38:04 +01:00
Jakub Jelinek
9715663f7d c++: Change __builtin_source_location to use __PRETTY_FUNCTION__ instead of __FUNCTION__ [PR80780]
On Tue, Dec 01, 2020 at 01:03:52PM +0000, Jonathan Wakely via Gcc-patches wrote:
> I mentioned in PR 80780 that a __builtin__PRETTY_FUNCTION would have
> been nice, because __FUNCTION__ isn't very useful for C++, because of
> overloading and namespace/class scopes. There are an unlimited number
> of functions that have __FUNCTION__ == "s", e.g. "ns::s(int)" and
> "ns::s()" and "another_scope::s::s<T...>(T...)" etc.
>
> Since __builtin_source_location() can do whatever it wants (without
> needing to add __builtin__PRETTY_FUNCTION) it might be nice to use the
> __PRETTY_FUNCTION__ string. JeanHeyd's tests would still need changes,
> because the name would be "s::s(void*)" not "s::s" but that still
> seems better for users.

When I've added template tests for the previous patch, I have noticed that
the current __builtin_source_location behavior is not really __FUNCTION__,
just close, because e.g. in function template __FUNCTION__ is still
"bar" but __builtin_source_location gave "bar<0>".

Anyway, this patch implements above request to follow __PRETTY_FUNCTION__
(on top of the earlier posted patch).

2020-12-04  Jakub Jelinek  <jakub@redhat.com>

	PR c++/80780
	* cp-gimplify.c (fold_builtin_source_location): Use 2 instead of 0
	as last argument to cxx_printable_name.

	* g++.dg/cpp2a/srcloc1.C (quux): Use __PRETTY_FUNCTION__ instead of
	function.
	* g++.dg/cpp2a/srcloc2.C (quux): Likewise.
	* g++.dg/cpp2a/srcloc15.C (S::S): Likewise.
	(bar): Likewise.  Adjust expected column.
	* g++.dg/cpp2a/srcloc17.C (S::S): Likewise.
	(bar): Likewise.  Adjust expected column.

	* testsuite/18_support/source_location/1.cc (main): Adjust for
	__builtin_source_location using __PRETTY_FUNCTION__-like names instead
	__FUNCTION__-like.
	* testsuite/18_support/source_location/consteval.cc (main): Likewise.
2020-12-04 08:08:39 +01:00
GCC Administrator
b8dd0ef74d Daily bump. 2020-12-04 00:16:36 +00:00
Jason Merrill
61371884fb c++: XFAIL testcase for PR98019
Apparently it isn't actually fixed on trunk yet, was just passing because of
some WIP in my tree.  So XFAIL for now.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-nodiscard1.C: XFAIL.
2020-12-03 17:59:01 -05:00
Jason Merrill
9a7f5e3906 c++: Fix bootstrap on 32-bit hosts [PR91828]
Using the releasing_vec op[] with an int index was breaking on 32-bit hosts
because of ambiguity with the built-in operator and the conversion
function.  Since the built-in operator has a ptrdiff_t, this was fine on
64-bit targets where ptrdiff_t is larger than int, but broke on 32-bit
targets where it's the same as int, making the conversion for that argument
better than the member function.  Fixed by changing the member function to
also use ptrdiff_t for the index.

gcc/cp/ChangeLog:

	* cp-tree.h (releasing_vec::operator[]): Change parameter type to
	ptrdiff_t.
2020-12-03 17:49:17 -05:00
Martin Sebor
dce6c58db8 Add support for detecting mismatched allocation/deallocation calls.
PR c++/90629 - Support for -Wmismatched-new-delete
PR middle-end/94527 - Add an __attribute__ that marks a function as freeing an object

gcc/ChangeLog:

	PR c++/90629
	PR middle-end/94527
	* builtins.c (access_ref::access_ref): Initialize new member.
	(compute_objsize): Use access_ref::deref.  Handle simple pointer
	assignment.
	(expand_builtin): Remove handling of the free built-in.
	(call_dealloc_argno): Same.
	(find_assignment_location): New function.
	(fndecl_alloc_p): Same.
	(gimple_call_alloc_p): Same.
	(call_dealloc_p): Same.
	(matching_alloc_calls_p): Same.
	(warn_dealloc_offset): Same.
	(maybe_emit_free_warning): Same.
	* builtins.h (struct access_ref): Declare new member.
	(maybe_emit_free_warning): Make extern.  Make use of access_ref.
	Handle -Wmismatched-new-delete.
	* calls.c (initialize_argument_information): Call
	maybe_emit_free_warning.
	* doc/extend.texi (attribute malloc): Update.
	* doc/invoke.texi (-Wfree-nonheap-object): Expand documentation.
	(-Wmismatched-new-delete): Document new option.
	(-Wmismatched-dealloc): Document new option.

gcc/c-family/ChangeLog:

	PR c++/90629
	PR middle-end/94527
	* c-attribs.c (handle_dealloc_attribute): New function.
	(handle_malloc_attribute): Handle argument forms of attribute.
	* c.opt (-Wmismatched-dealloc): New option.
	(-Wmismatched-new-delete): New option.

gcc/testsuite/ChangeLog:

	PR c++/90629
	PR middle-end/94527
	* g++.dg/asan/asan_test.cc: Fix a bug.
	* g++.dg/warn/delete-array-1.C: Add expected warning.
	* g++.old-deja/g++.other/delete2.C: Add expected warning.
	* g++.dg/warn/Wfree-nonheap-object-2.C: New test.
	* g++.dg/warn/Wfree-nonheap-object.C: New test.
	* g++.dg/warn/Wmismatched-new-delete.C: New test.
	* g++.dg/warn/Wmismatched-dealloc-2.C: New test.
	* g++.dg/warn/Wmismatched-dealloc.C: New test.
	* gcc.dg/Wmismatched-dealloc.c: New test.
	* gcc.dg/analyzer/malloc-1.c: Prune out expected warning.
	* gcc.dg/attr-malloc.c: New test.
	* gcc.dg/free-1.c: Adjust text of expected warning.
	* gcc.dg/free-2.c: Same.
	* gcc.dg/torture/pr71816.c: Prune out expected warning.
	* gcc.dg/tree-ssa/pr19831-2.c: Add an expected warning.
	* gcc.dg/Wfree-nonheap-object-2.c: New test.
	* gcc.dg/Wfree-nonheap-object-3.c: New test.
	* gcc.dg/Wfree-nonheap-object.c: New test.

libstdc++-v3/ChangeLog:

	* testsuite/ext/vstring/modifiers/clear/56166.cc: Suppress a false
	positive warning.
2020-12-03 15:43:32 -07:00
Nathan Sidwell
a3f7a6957a c++: Exported using decls
With modules we need to record whethe a (namespace-scope) using decl
is exporting the named entities.  Record this on the OVERLOAD marking
the used decl.

	gcc/cp/
	* cp-tree.h (OVL_EXPORT): New.
	(class ovl_iterator): Add get_using, exporting_p.
	* tree.c (ovl_insert): Extend using_or_hidden meaning to include
	an exported using.
2020-12-03 12:40:09 -08:00
Nathan Sidwell
f7aeb823d9 c++: uninstantiated template friends
template friends need to be recognized by module streaming and
associated with the befriending class.  but their context is that of
the friend (a namespace or other class).  This adds a flag to mark
such templates, and uses their DECL_CHAIN to point at the befriender.

	gcc/cp
	* cp-tree.h (DECL_UNINSTANTIATED_TEMPLATE_FRIEND): New.
	* pt.c (push_template_decl): Set it.
	(tsubst_friend_function): Clear it.
2020-12-03 12:40:09 -08:00
Ian Lance Taylor
3089f5feef Go testsuite: update new tests to version in source repo 2020-12-03 12:08:05 -08:00
Michael Meissner
9f1a650199 PowerPC: PR libgcc/97543 and libgcc/97643, fix long double issues
If you use a compiler with long double defaulting to 64-bit instead of 128-bit
with IBM extended double, you get linker warnings about mis-matches in the gnu
attributes for long double (PR libgcc/97543).  Even if the compiler is
configured to have long double be 64 bit as the default with the configuration
option '--without-long-double-128' you get the warnings.

You also get the same issues if you use a compiler with long double defaulting
to IEEE 128-bit instead of IBM extended double (PR libgcc/97643).

The issue is the way libgcc.a/libgcc.so is built.  Right now when building
libgcc under Linux, the long double size is set to 128-bits when building
libgcc.  However, the gnu attributes are set, leading to the warnings.

One feature of the current GNU attribute implementation is if you have a shared
library (such as libgcc_s.so), the GNU attributes for the shared library is an
inclusive OR of all of the objects within the library.  This means if any
object file that uses the -mlong-double-128 option and uses long double, the GNU
attributes for the library will indicate that it uses 128-bit IBM long
doubles.  If you have a static library, you will get the warning only if you
actually reference an object file  with the attribute set.

This patch does two things:

    1)	All of the object files that support IBM 128-bit long doubles
	explicitly set the ABI to IBM extended double.

    2)	I turned off GNU attributes for building the shared library or for
        building the IBM 128-bit long double support.

libgcc/
2020-12-03  Michael Meissner  <meissner@linux.ibm.com>

	PR libgcc/97543
	PR libgcc/97643
	* config/rs6000/t-linux (IBM128_STATIC_OBJS): New make variable.
	(IBM128_SHARED_OBJS): New make variable.
	(IBM128_OBJS): New make variable.  Set all objects to use the
	explicit IBM format, and disable gnu attributes.
	(IBM128_CFLAGS): New make variable.
	(gcc_s_compile): Add -mno-gnu-attribute to all shared library
	modules.
2020-12-03 14:50:26 -05:00
Harald Anlauf
30b606bb9b PR fortran/95342 - ICE in gfc_match_subroutine, at fortran/decl.c:7913
Add checks for NULL pointers before dereferencing them.

gcc/fortran/ChangeLog:

	PR fortran/95342
	* decl.c (gfc_match_function_decl): Avoid NULL pointer dereference.
	(gfc_match_subroutine): Likewise.

gcc/testsuite/ChangeLog:

	PR fortran/95342
	* gfortran.dg/pr95342.f90: New test.
2020-12-03 20:33:22 +01:00
Jonathan Wakely
656131e06a libstdc++: Fix typos in #error strings
libstdc++-v3/ChangeLog:

	* testsuite/26_numerics/bit/bit.cast/bit_cast.cc: Remove stray
	word from copy&paste.
	* testsuite/26_numerics/bit/bit.cast/version.cc: Likewise.
2020-12-03 19:31:19 +00:00
Alexandre Oliva
442b6fb7c0 fix __builtin___clear_cache overrider fallout
Machines that had CLEAR_CACHE_INSN and that would thus issue calls to
__clear_cache with the default call expander, would fail on languages
that did not set up the __clear_cache builtin.  This patch arranges
for all languages to set up this builtin.

Machines or multilibs that had ptr_mode != Pmode, such as aarch64 with
-mabi=ilp32, would fail the RTL mode test of the arguments passed to
__clear_cache, because we'd insist on ptr_mode.  This patch arranges
for Pmode to be accepted as well.


for  gcc/ChangeLog

	* tree.c (build_common_builtin_nodes): Declare
	__builtin___clear_cache for all languages.
	* builtins.c (maybe_emit_call_builtin___clear_cache): Accept
	Pmode arguments.
2020-12-03 16:20:28 -03:00
Jonathan Wakely
44ac1ea0e2 libstdc++: Update C++20 library implementation status
libstdc++-v3/ChangeLog:

	* doc/xml/manual/status_cxx2020.xml: Update C++20 status.
	* doc/html/*: Regenerate.
2020-12-03 19:17:13 +00:00
JeanHeyd Meneide
57d76ee9cf libtdc++: Define std::source_location for C++20
This doesn't define a new _GLIBCXX_HAVE_BUILTIN_SOURCE_LOCATION macro.
because using __has_builtin(__builtin_source_location) is sufficient.
Currently only GCC supports it, but if/when Clang and Intel add it the
__has_builtin check should for them too.

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in (INPUT): Add <source_location>.
	* include/Makefile.am: Add <source_location>.
	* include/Makefile.in: Regenerate.
	* include/std/version (__cpp_lib_source_location): Define.
	* include/std/source_location: New file.
	* testsuite/18_support/source_location/1.cc: New test.
	* testsuite/18_support/source_location/consteval.cc: New test.
	* testsuite/18_support/source_location/srcloc.h: New test.
	* testsuite/18_support/source_location/version.cc: New test.
2020-12-03 19:17:13 +00:00
Jonathan Wakely
9e433b3461 libstdc++: Add std::bit_cast for C++20 [PR 93121]
Thanks to Jakub's addition of the built-in, we can add this to the
library now. The compiler tests for the built-in are quite extensive,
including verifying the constraints, so this only adds minimal tests to
the library testsuite.

This doesn't add a new _GLIBCXX_HAVE_BUILTIN_BIT_CAST because using
__has_builtin(__builtin_bit_cast) works for GCC and versions of Clang
that provide the built-in.

libstdc++-v3/ChangeLog:

	PR libstdc++/93121
	* include/std/bit (__cpp_lib_bit_cast, bit_cast): Define.
	* include/std/version (__cpp_lib_bit_cast): Define.
	* testsuite/26_numerics/bit/bit.cast/bit_cast.cc: New test.
	* testsuite/26_numerics/bit/bit.cast/version.cc: New test.
2020-12-03 19:17:13 +00:00
Ian Lance Taylor
adbeeb198a Go testsuite: add a bunch of new tests from source repo 2020-12-03 11:13:03 -08:00
Ian Lance Taylor
2a099fd223 go-test.exp: add -I. when compiling in directory
* go.test/go-test.exp (go-gc-tests): Add -I. when building all
	sources in a directory (errorcheckdir, compiledir, rundir,
	rundircmpout).
2020-12-03 11:11:28 -08:00
Jason Merrill
5ea36d20c3 c++: Add testcase for PR98019
This has already been fixed on trunk, but I don't see a testcase for it.

gcc/testsuite/ChangeLog:

	PR c++/98019
	* g++.dg/cpp2a/concepts-nodiscard1.C: New test.
2020-12-03 13:56:56 -05:00
Ian Lance Taylor
4a3b9f48c3 testsuite: update existing Go tests to source repo
This updates a bunch of existing Go tests to the contents of the
source repo.  This does not add any of the newer tests.
2020-12-03 10:09:48 -08:00
Sebastian Huber
2fb287056e RTEMS: Add Cortex-R52 multilib
gcc/
	* config/arm/t-rtems: Add "-mthumb -mcpu=cortex-r52
	-mfloat-abi=hard" multilib.
2020-12-03 18:51:41 +01:00
Jonathan Wakely
3843fa2d75 libstdc++: Update powerpc-linux baselines for GCC 10.1
This should have been done before the GCC 10.1 release.

libstdc++-v3/ChangeLog:

	* config/abi/post/powerpc-linux-gnu/baseline_symbols.txt:
	Update.
	* config/abi/post/powerpc64-linux-gnu/32/baseline_symbols.txt:
	Update.
2020-12-03 17:18:28 +00:00
Jonathan Wakely
91cfacc4b5 libstdc++: Disable std::array assertions for C++11 constexpr
The recent changes to add assertions to std::array broke the functions
that need to be constexpr in C++11, because of the restrictive rules for
constexpr functions in C++11.

This simply disables the assertions for C++11 mode, so the functions can
be constexpr again.

libstdc++-v3/ChangeLog:

	* include/std/array (array::operator[](size_t) const, array::front() const)
	(array::back() const) [__cplusplus == 201103]: Disable
	assertions.
	* testsuite/23_containers/array/element_access/constexpr_element_access.cc:
	Check for correct values.
	* testsuite/23_containers/array/tuple_interface/get_neg.cc:
	Adjust dg-error line numbers.
	* testsuite/23_containers/array/debug/constexpr_c++11.cc: New test.
2020-12-03 17:08:01 +00:00
Nathan Sidwell
eb8c2b30b9 c++: templatey type creation
This patch makes a couple of type-creation routines available to
modules.  That needs to create unbound template parms, and canonical
template parms.

	gcc/cp/
	* cp-tree.h (make_unbound_class_template_raw): Declare.
	(canonical_type_parameter): Declare.
	* decl.c (make_unbound_class_template_raw): Break out of ...
	(make_unboud_class_template): ... here.  Call it.
	* pt.c (canonical_type_parameter): Externalize.  Refactor & set
	structural_equality for type parms.
2020-12-03 09:01:43 -08:00
Uros Bizjak
756f55e62f i386: Fix up ix86_md_asm_adjust for TImode [PR98086]
ix86_md_asm_adjust assumes that dest_mode can be only [QHSD]Imode
and nothing else.  The patch rewrites zero-extension part to use
convert_to_mode to handle TImode and hypothetically even wider modes.

2020-12-03  Uroš Bizjak  <ubizjak@gmail.com>
	    Jakub Jelinek  <jakub@redhat.com>

gcc/
	PR target/98086
	* config/i386/i386.c (ix86_md_asm_adjustmd): Rewrite
	zero-extension part to use convert_to_mode.

gcc/testsuite/
	PR target/98086
	* gcc.target/i386/pr98086.c: New test.
2020-12-03 17:51:45 +01:00
Nathan Sidwell
7254a78cf4 c++: Testcases [PR 98115]
These two testcases provide coverage for 98115, which doesn't trigger on all hosts.

	PR c++/98115
	PR c++/98116
	gcc/testsuite/
	* g++.dg/template/pr98115.C: New.
	* g++.dg/template/pr98116.C: New.
2020-12-03 08:43:32 -08:00