Joseph Myers [Fri, 28 Oct 2022 14:40:25 +0000 (14:40 +0000)]
c: tree: target: C2x (...) function prototypes and va_start relaxation
C2x allows function prototypes to be given as (...), a prototype
meaning a variable-argument function with no named arguments. To
allow such functions to access their arguments, requirements for
va_start calls are relaxed so it ignores all but its first argument
(i.e. subsequent arguments, if any, can be arbitrary pp-token
sequences).
Implement this feature accordingly. The va_start relaxation in
<stdarg.h> is itself easy: __builtin_va_start already supports a
second argument of 0 instead of a parameter name, and calls get
converted internally to the form using 0 for that argument, so
<stdarg.h> just needs changing to use a variadic macro that passes 0
as the second argument of __builtin_va_start. (This is done only in
C2x mode, on the expectation that users of older standard would expect
unsupported uses of va_start to be diagnosed.)
For the (...) functions, it's necessary to distinguish these from
unprototyped functions, whereas previously C++ (...) functions and
unprototyped functions both used NULL TYPE_ARG_TYPES. A flag is added
to tree_type_common to mark the (...) functions; as discussed on gcc@,
doing things this way is likely to be safer for unchanged code in GCC
than adding a different form of representation in TYPE_ARG_TYPES, or
adding a flag that instead signals that the function is unprototyped.
There was previously an option
-fallow-parameterless-variadic-functions to enable support for (...)
prototypes. The support was incomplete - it treated the functions as
unprototyped, and only parsed some declarations, not e.g.
"int g (int (...));". This option is changed into a no-op ignored
option; (...) is always accepted syntactically, with a pedwarn_c11
call to given required diagnostics when appropriate. The peculiarity
of a parameter list with __attribute__ followed by '...' being
accepted with that option is removed.
Interfaces in tree.cc that create function types are adjusted to set
this flag as appropriate. It is of course possible that some existing
users of the functions to create variable-argument functions actually
wanted unprototyped functions in the no-named-argument case, rather
than functions with a (...) prototype; some such cases in c-common.cc
(for built-in functions and implicit function declarations) turn out
to need updating for that reason.
I didn't do anything to change how the C++ front end creates (...)
function types. It's very likely there are unchanged places in the
compiler that in fact turn out to need changes to work properly with
(...) function prototypes.
Target setup_incoming_varargs hooks, where they used the information
passed about the last named argument, needed updating to avoid using
that information in the (...) case. Note that apart from the x86
changes, I haven't done any testing of those target changes beyond
building cc1 to check for syntax errors. It's possible further
target-specific fixes will be needed; target maintainers should watch
out for failures of c2x-stdarg-4.c or c2x-stdarg-split-1a.c, the
execution tests, which would indicate that this feature is not working
correctly. Those tests also verify the case where there are named
arguments but the last named argument has a declaration that results
in undefined behavior in previous C standard versions, such as a type
changed by the default argument promotions.
Bootstrapped with no regressions for x86_64-pc-linux-gnu.
gcc/
* config/aarch64/aarch64.cc (aarch64_setup_incoming_varargs):
Check TYPE_NO_NAMED_ARGS_STDARG_P.
* config/alpha/alpha.cc (alpha_setup_incoming_varargs): Likewise.
* config/arc/arc.cc (arc_setup_incoming_varargs): Likewise.
* config/arm/arm.cc (arm_setup_incoming_varargs): Likewise.
* config/csky/csky.cc (csky_setup_incoming_varargs): Likewise.
* config/epiphany/epiphany.cc (epiphany_setup_incoming_varargs):
Likewise.
* config/fr30/fr30.cc (fr30_setup_incoming_varargs): Likewise.
* config/frv/frv.cc (frv_setup_incoming_varargs): Likewise.
* config/ft32/ft32.cc (ft32_setup_incoming_varargs): Likewise.
* config/i386/i386.cc (ix86_setup_incoming_varargs): Likewise.
* config/ia64/ia64.cc (ia64_setup_incoming_varargs): Likewise.
* config/loongarch/loongarch.cc
(loongarch_setup_incoming_varargs): Likewise.
* config/m32r/m32r.cc (m32r_setup_incoming_varargs): Likewise.
* config/mcore/mcore.cc (mcore_setup_incoming_varargs): Likewise.
* config/mips/mips.cc (mips_setup_incoming_varargs): Likewise.
* config/mmix/mmix.cc (mmix_setup_incoming_varargs): Likewise.
* config/nds32/nds32.cc (nds32_setup_incoming_varargs): Likewise.
* config/nios2/nios2.cc (nios2_setup_incoming_varargs): Likewise.
* config/riscv/riscv.cc (riscv_setup_incoming_varargs): Likewise.
* config/rs6000/rs6000-call.cc (setup_incoming_varargs): Likewise.
* config/sh/sh.cc (sh_setup_incoming_varargs): Likewise.
* config/visium/visium.cc (visium_setup_incoming_varargs):
Likewise.
* config/vms/vms-c.cc (vms_c_common_override_options): Do not set
flag_allow_parameterless_variadic_functions.
* doc/invoke.texi (-fallow-parameterless-variadic-functions): Do
not document option.
* function.cc (assign_parms): Call assign_parms_setup_varargs for
TYPE_NO_NAMED_ARGS_STDARG_P case.
* ginclude/stdarg.h [__STDC_VERSION__ > 201710L] (va_start): Make
variadic macro. Pass second argument of 0 to __builtin_va_start.
* target.def (setup_incoming_varargs): Update documentation.
* doc/tm.texi: Regenerate.
* tree-core.h (struct tree_type_common): Add
no_named_args_stdarg_p.
* tree-streamer-in.cc (unpack_ts_type_common_value_fields): Unpack
TYPE_NO_NAMED_ARGS_STDARG_P.
* tree-streamer-out.cc (pack_ts_type_common_value_fields): Pack
TYPE_NO_NAMED_ARGS_STDARG_P.
* tree.cc (type_cache_hasher::equal): Compare
TYPE_NO_NAMED_ARGS_STDARG_P.
(build_function_type): Add argument no_named_args_stdarg_p.
(build_function_type_list_1, build_function_type_array_1)
(reconstruct_complex_type): Update calls to build_function_type.
(stdarg_p, prototype_p): Return true for (...) functions.
(gimple_canonical_types_compatible_p): Compare
TYPE_NO_NAMED_ARGS_STDARG_P.
* tree.h (TYPE_NO_NAMED_ARGS_STDARG_P): New.
(build_function_type): Update prototype.
gcc/c-family/
* c-common.cc (def_fn_type): Call build_function_type for
zero-argument variable-argument function.
(c_common_nodes_and_builtins): Build default_function_type with
build_function_type.
* c.opt (fallow-parameterless-variadic-functions): Mark as ignored
option.
gcc/c/
* c-decl.cc (grokdeclarator): Pass
arg_info->no_named_args_stdarg_p to build_function_type.
(grokparms): Check arg_info->no_named_args_stdarg_p before
converting () to (void).
(build_arg_info): Initialize no_named_args_stdarg_p.
(get_parm_info): Set no_named_args_stdarg_p.
(start_function): Pass TYPE_NO_NAMED_ARGS_STDARG_P to
build_function_type.
(store_parm_decls): Count (...) functions as prototyped.
* c-parser.cc (c_parser_direct_declarator): Allow '...' after open
parenthesis to start parameter list.
(c_parser_parms_list_declarator): Always allow '...' with no
arguments, call pedwarn_c11 and set no_named_args_stdarg_p.
* c-tree.h (struct c_arg_info): Add field no_named_args_stdarg_p.
* c-typeck.cc (composite_type): Handle
TYPE_NO_NAMED_ARGS_STDARG_P.
(function_types_compatible_p): Compare
TYPE_NO_NAMED_ARGS_STDARG_P.
gcc/fortran/
* trans-types.cc (gfc_get_function_type): Do not use
build_varargs_function_type_vec for unprototyped function.
gcc/lto/
* lto-common.cc (compare_tree_sccs_1): Compare
TYPE_NO_NAMED_ARGS_STDARG_P.
gcc/objc/
* objc-next-runtime-abi-01.cc (build_next_objc_exception_stuff):
Use build_function_type to build type of objc_setjmp_decl.
gcc/testsuite/
* gcc.dg/c11-stdarg-1.c, gcc.dg/c11-stdarg-2.c,
gcc.dg/c11-stdarg-3.c, gcc.dg/c2x-stdarg-1.c,
gcc.dg/c2x-stdarg-2.c, gcc.dg/c2x-stdarg-3.c,
gcc.dg/c2x-stdarg-4.c, gcc.dg/gnu2x-stdarg-1.c,
gcc.dg/torture/c2x-stdarg-split-1a.c,
gcc.dg/torture/c2x-stdarg-split-1b.c: New tests.
* gcc.dg/Wold-style-definition-2.c, gcc.dg/format/sentinel-1.c:
Update expected diagnostics.
* gcc.dg/c2x-nullptr-1.c (test5): Cast unused parameter to (void).
* gcc.dg/diagnostic-token-ranges.c: Use -pedantic. Expect warning
in place of error.
Jonathan Wakely [Tue, 25 Oct 2022 12:03:12 +0000 (13:03 +0100)]
libstdc++: Fix allocator propagation in regex algorithms [PR107376]
The PR points out that we assume the match_results allocator is default
constuctible, which might not be true. We also have a related issue with
unwanted propagation from an object that might have an unequal
allocator.
Ideally we use the same allocator type for _State_info::_M_match_queue
but that would be an ABI change now. We should investigate if that can
be done without breaking anything, which might be possible because the
_Executor object is short-lived and never leaks out of the regex_match,
regex_search, and regex_replace algorithms. If we change the mangled
name for _Executor then there would be no ODR violations when mixing old
and new definitions. This commit does not attempt that.
libstdc++-v3/ChangeLog:
PR libstdc++/107376
* include/bits/regex_executor.h (_Executor::_Executor): Use same
allocator for _M_cur_results and _M_results.
* include/bits/regex_executor.tcc (_Executor::_M_main_dispatch):
Prevent possibly incorrect allocator propagating to
_M_cur_results.
* testsuite/28_regex/algorithms/regex_match/107376.cc: New test.
Andre Vieira [Fri, 28 Oct 2022 14:05:11 +0000 (15:05 +0100)]
vect: Reject non-byte offsets for gather/scatters [PR107346]
The ada failure reported in the PR was being caused by vect_check_gather_scatter
failing to deal with bit offsets that weren't multiples of BITS_PER_UNIT. This
patch makes vect_check_gather_scatter reject memory accesses with such offsets.
gcc/ChangeLog:
PR tree-optimization/107346
* tree-vect-data-refs.cc (vect_check_gather_scatter): Reject offsets
that aren't multiples of BITS_PER_UNIT.
Richard Biener [Fri, 28 Oct 2022 13:03:49 +0000 (15:03 +0200)]
tree-optimization/107407 - wrong code with DSE
So what happens is that we elide processing of this check with
/* In addition to kills we can remove defs whose only use
is another def in defs. That can only ever be PHIs of which
we track two for simplicity reasons, the first and last in
{first,last}_phi_def (we fail for multiple PHIs anyways).
We can also ignore defs that feed only into
already visited PHIs. */
else if (single_imm_use (vdef, &use_p, &use_stmt)
&& (use_stmt == first_phi_def
|| use_stmt == last_phi_def
|| (gimple_code (use_stmt) == GIMPLE_PHI
&& bitmap_bit_p (visited,
SSA_NAME_VERSION
(PHI_RESULT (use_stmt))))))
where we have the last PHI being the outer loop virtual PHI and the first
PHI being the loop exit PHI of the outer loop and we've already processed
the single immediate use of the outer loop PHI, the inner loop PHI. But
we still have to perform the above check!
It's easiest to perform the check when we visit the PHI node instead of
delaying it to the actual processing loop.
PR tree-optimization/107407
* tree-ssa-dse.cc (dse_classify_store): Perform backedge
varying index check when collecting PHI uses rather than
after optimizing processing of the candidate defs.
* gcc.dg/torture/pr107407.c: New testcase.
Richard Biener [Fri, 28 Oct 2022 12:20:36 +0000 (14:20 +0200)]
tree-optimization/107447 - avoid hoisting returns-twice calls in LIM
The following makes sure to not hoist returns-twice calls in LIM
since we have no way to move the abnormal edge associated with it
and we are prone having stray abnormal edges in the IL which will
then cause IL verification failures even when the actual call
does not return twice.
PR tree-optimization/107447
* tree-ssa-loop-im.cc (determine_max_movement): Do not
hoist returns-twice calls.
* gcc.dg/torture/pr107447.c: New testcase.
Richard Biener [Fri, 28 Oct 2022 11:50:57 +0000 (13:50 +0200)]
tree-optimization/107435 - ICE with recurrence vectorization
This implements the missed conversion from pointer to integer.
PR tree-optimization/107435
* tree-vect-loop.cc (vectorizable_recurr): Convert initial
value to vector component type.
* gcc.dg/torture/pr107435.c: New testcase.
Jakub Jelinek [Fri, 28 Oct 2022 09:03:56 +0000 (11:03 +0200)]
openmp: Allow optional comma after directive-specifier in C/C++
Previously we've been allowing that comma only in C++ when in attribute
form (which was the reason why it has been allowed), but 5.1 allows that
even in pragma form in C/C++ (with clarifications in 5.2) and 5.2
also in Fortran (which this patch doesn't implement).
Note, for directives which take an argument (== unnamed clause),
comma is not allowed in between the directive name and the argument,
like the directive-1.c testcase shows.
2022-10-28 Jakub Jelinek <jakub@redhat.com>
gcc/c/
* c-parser.cc (c_parser_omp_all_clauses): Allow optional
comma before the first clause.
(c_parser_omp_allocate, c_parser_omp_atomic, c_parser_omp_depobj,
c_parser_omp_flush, c_parser_omp_scan_loop_body,
c_parser_omp_ordered, c_finish_omp_declare_variant,
c_parser_omp_declare_target, c_parser_omp_declare_reduction,
c_parser_omp_requires, c_parser_omp_error,
c_parser_omp_assumption_clauses): Likewise.
gcc/cp/
* parser.cc (cp_parser_omp_all_clauses): Allow optional comma
before the first clause even in pragma syntax.
(cp_parser_omp_allocate, cp_parser_omp_atomic, cp_parser_omp_depobj,
cp_parser_omp_flush, cp_parser_omp_scan_loop_body,
cp_parser_omp_ordered, cp_parser_omp_assumption_clauses,
cp_finish_omp_declare_variant, cp_parser_omp_declare_target,
cp_parser_omp_declare_reduction_exprs, cp_parser_omp_requires,
cp_parser_omp_error): Likewise.
gcc/testsuite/
* c-c++-common/gomp/directive-1.c: New test.
* c-c++-common/gomp/clauses-6.c: New test.
* c-c++-common/gomp/declare-variant-2.c (f75a): Declare.
(f75): Use f75a as variant instead of f1 and don't expect error.
* g++.dg/gomp/clause-4.C (foo): Don't expect error on comma
before first clause.
* gcc.dg/gomp/clause-2.c (foo): Likewise.
Richard Biener [Fri, 28 Oct 2022 08:31:02 +0000 (10:31 +0200)]
Adjust gcc.dg/vect/pr100756.c for V8SI and V16SI
The following adjusts the testcase to require no epilogue also
for larger vectors than V4SI.
* gcc.dg/vect/pr100756.c: Adjust for larger vectors.
Julian Brown [Wed, 12 Oct 2022 20:44:57 +0000 (20:44 +0000)]
OpenACC: Don't gang-privatize artificial variables [PR90115]
This patch prevents compiler-generated artificial variables from being
treated as privatization candidates for OpenACC.
The rationale is that e.g. "gang-private" variables actually must be
shared by each worker and vector spawned within a particular gang, but
that sharing is not necessary for any compiler-generated variable (at
least at present, but no such need is anticipated either). Variables on
the stack (and machine registers) are already private per-"thread"
(gang, worker and/or vector), and that's fine for artificial variables.
We're restricting this to blocks, as we still need to understand what it
means for a 'DECL_ARTIFICIAL' to appear in a 'private' clause.
Several tests need their scan output patterns adjusted to compensate.
2022-10-14 Julian Brown <julian@codesourcery.com>
PR middle-end/90115
gcc/
* omp-low.cc (oacc_privatization_candidate_p): Artificial vars are not
privatization candidates.
libgomp/
* testsuite/libgomp.oacc-fortran/declare-1.f90: Adjust scan output.
* testsuite/libgomp.oacc-fortran/host_data-5.F90: Likewise.
* testsuite/libgomp.oacc-fortran/if-1.f90: Likewise.
* testsuite/libgomp.oacc-fortran/print-1.f90: Likewise.
* testsuite/libgomp.oacc-fortran/privatized-ref-2.f90: Likewise.
Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
Thomas Schwinge [Tue, 25 Oct 2022 11:10:52 +0000 (13:10 +0200)]
Fix target selector syntax in 'gcc.dg/vect/bb-slp-cond-1.c'
... to restore testing lost in recent
commit r13-3225-gbd9a05594d227cde79a67dc715bd9d82e9c464e9
"amdgcn: vector testsuite tweaks" (for example, x86_64-pc-linux-gnu):
PASS: gcc.dg/vect/bb-slp-cond-1.c (test for excess errors)
PASS: gcc.dg/vect/bb-slp-cond-1.c -flto -ffat-lto-objects scan-tree-dump vect "(no need for alias check [^\\n]* when VF is 1|no alias between [^\\n]* when [^\\n]* is outside \\(-16, 16\\))"
[-PASS: gcc.dg/vect/bb-slp-cond-1.c -flto -ffat-lto-objects scan-tree-dump-times vect "loop vectorized" 1-]
PASS: gcc.dg/vect/bb-slp-cond-1.c -flto -ffat-lto-objects (test for excess errors)
PASS: gcc.dg/vect/bb-slp-cond-1.c -flto -ffat-lto-objects execution test
PASS: gcc.dg/vect/bb-slp-cond-1.c execution test
PASS: gcc.dg/vect/bb-slp-cond-1.c scan-tree-dump vect "(no need for alias check [^\\n]* when VF is 1|no alias between [^\\n]* when [^\\n]* is outside \\(-16, 16\\))"
[-PASS: gcc.dg/vect/bb-slp-cond-1.c scan-tree-dump-times vect "loop vectorized" 1-]
gcc/testsuite/
* gcc.dg/vect/bb-slp-cond-1.c: Fix target selector syntax.
Martin Liska [Wed, 26 Oct 2022 11:07:57 +0000 (13:07 +0200)]
docs: document sanitizers can trigger warnings
PR sanitizer/107298
gcc/ChangeLog:
* doc/invoke.texi: Document sanitizers can trigger warnings.
Martin Liska [Thu, 27 Oct 2022 08:40:58 +0000 (10:40 +0200)]
lto-dump: modernize a bit
gcc/lto/ChangeLog:
* lto-dump.cc (dump_list): Remove trailing return.
(dump_symbol): Likewise.
(dump_body): Filter name based on mangled name.
(dump_tool_help): Use GIMPLE wording.
(lto_main): Update wording.
Thomas Schwinge [Wed, 26 Oct 2022 11:07:27 +0000 (13:07 +0200)]
Document 'distclean-stage[N]'
Refer to 'Makefile.tpl':
# Rules to wipe a stage and all the following ones, also used for cleanstrap
[+ IF prev +]distclean-stage[+prev+]:: distclean-stage[+id+] [+ ENDIF prev +]
.PHONY: distclean-stage[+id+]
distclean-stage[+id+]::
@: $(MAKE); $(stage)
@test "`cat stage_last`" != stage[+id+] || rm -f stage_last
rm -rf stage[+id+]-* [+
IF compare-target +][+compare-target+] [+ ENDIF compare-target +]
gcc/
* doc/makefile.texi (Makefile Targets): Document
'distclean-stage[N]'.
Aldy Hernandez [Fri, 28 Oct 2022 06:13:38 +0000 (08:13 +0200)]
Change remaining flag_finite_math_only use in value-range.cc.
gcc/ChangeLog:
* value-range.cc (range_tests_floats): Use HONOR_INFINITIES.
Kewen Lin [Fri, 28 Oct 2022 03:30:16 +0000 (22:30 -0500)]
testsuite: Adjust vect-bitfield-read-* with vect_shift and vect_long_long [PR107240]
The test cases vect-bitfield-read-* requires vector shift
target support, they need one explicit vect_shift effective
target requirement checking. Besides, the vectype for struct
in test cases vect-bitfield-read-{2,4} is vector of long long,
we need to check effective target vect_long_long for them.
This patch can help to fix all remaining vect-bitfield-{read,
write}-* test failures on powerpc.
PR testsuite/107240
gcc/testsuite/ChangeLog:
* gcc.dg/vect/vect-bitfield-read-1.c: Add effective target checking
vect_shift.
* gcc.dg/vect/vect-bitfield-read-3.c: Likewise.
* gcc.dg/vect/vect-bitfield-read-5.c: Likewise.
* gcc.dg/vect/vect-bitfield-read-6.c: Likewise.
* gcc.dg/vect/vect-bitfield-read-7.c: Likewise.
* gcc.dg/vect/vect-bitfield-read-2.c: Add effective target checking
vect_shift and replace vect_int with vect_long_long.
* gcc.dg/vect/vect-bitfield-read-4.c: Likewise.
Joseph Myers [Fri, 28 Oct 2022 00:37:28 +0000 (00:37 +0000)]
c: C2x enums with fixed underlying type [PR61469]
C2x adds support for enums with a fixed underlying type specified
("enum e : long long;" and similar). Implement this in the C front
end. The same representation is used for these types as in C++, with
two macros moved from cp-tree.h to c-common.h.
Such enums can have bool as the underlying type, and various C
front-end code checking for boolean types is adjusted to use a new
C_BOOLEAN_TYPE_P to handle such enums the same way as bool. (Note
that for C++ we have bug 96496 that enums with underlying type bool
don't work correctly there.)
There are various issues with the wording for such enums in the
current C2x working draft (including but not limited to wording in the
accepted paper that failed to make it into the working draft), which I
intend to raise in NB comments. I think what I've implemented and
added tests for matches the intent.
Bootstrapped with no regressions for x86_64-pc-linux-gnu.
PR c/61469
gcc/c-family/
* c-common.h (ENUM_UNDERLYING_TYPE, ENUM_FIXED_UNDERLYING_TYPE_P):
New. Moved from cp/cp-tree.h.
* c-warn.cc (warnings_for_convert_and_check): Do not consider
conversions to enum with underlying type bool to overflow.
gcc/c/
* c-convert.cc (c_convert): Handle enums with underlying boolean
type like bool.
* c-decl.cc (shadow_tag_warned): Allow shadowing declarations for
enums with enum type specifier, but give errors for storage class
specifiers, qualifiers or alignment specifiers in non-definition
declarations of such enums.
(grokdeclarator): Give error for non-definition use of type
specifier with an enum type specifier.
(parser_xref_tag): Add argument has_enum_type_specifier. Pass it
to lookup_tag and use it to set ENUM_FIXED_UNDERLYING_TYPE_P.
(xref_tag): Update call to parser_xref_tag.
(start_enum): Add argument fixed_underlying_type. Complete enum
type with a fixed underlying type given in the definition. Give
error for defining without a fixed underlying type in the
definition if one was given in a prior declaration. Do not mark
enums with fixed underlying type as packed for -fshort-enums.
Store the enum type in the_enum.
(finish_enum): Do not adjust types of values or check their range
for an enum with a fixed underlying type. Set underlying type of
enum and variants.
(build_enumerator): Check enumeration constants for enum with
fixed underlying type against that type and convert to that type.
Increment in the underlying integer type, with handling for bool.
(c_simulate_enum_decl): Update call to start_enum.
(declspecs_add_type): Set specs->enum_type_specifier_ref_p.
* c-objc-common.cc (c_get_alias_set): Use ENUM_UNDERLYING_TYPE
rather than recomputing an underlying type based on size.
* c-parser.cc (c_parser_declspecs)
(c_parser_struct_or_union_specifier, c_parser_typeof_specifier):
Set has_enum_type_specifier for type specifiers.
(c_parser_enum_specifier): Handle enum type specifiers.
(c_parser_struct_or_union_specifier): Update call to
parser_xref_tag.
(c_parser_omp_atomic): Check for boolean increment or decrement
using C_BOOLEAN_TYPE_P.
* c-tree.h (C_BOOLEAN_TYPE_P): New.
(struct c_typespec): Add has_enum_type_specifier.
(struct c_declspecs): Add enum_type_specifier_ref_p.
(struct c_enum_contents): Add enum_type.
(start_enum, parser_xref_tag): Update prototypes.
* c-typeck.cc (composite_type): Allow for enumerated types
compatible with bool.
(common_type, comptypes_internal, perform_integral_promotions):
Use ENUM_UNDERLYING_TYPE.
(parser_build_binary_op, build_unary_op, convert_for_assignment)
(c_finish_return, c_start_switch, build_binary_op): Check for
boolean types using C_BOOLEAN_TYPE_P.
gcc/cp/
* cp-tree.h (ENUM_FIXED_UNDERLYING_TYPE_P, ENUM_UNDERLYING_TYPE):
Remove. Moved to c-common.h.
gcc/testsuite/
* gcc.dg/c11-enum-4.c, gcc.dg/c11-enum-5.c, gcc.dg/c11-enum-6.c,
gcc.dg/c2x-enum-6.c, gcc.dg/c2x-enum-7.c, gcc.dg/c2x-enum-8.c,
gcc.dg/gnu2x-enum-1.c: New tests.
GCC Administrator [Fri, 28 Oct 2022 00:18:03 +0000 (00:18 +0000)]
Daily bump.
Ian Lance Taylor [Thu, 27 Oct 2022 00:23:42 +0000 (17:23 -0700)]
runtime: use _libgo_off_t_type when calling C mmap
The last argument to the C mmap function is type off_t, not uintptr.
On some 32-bit systems, off_t is larger than uintptr.
Based on patch by Sören Tempel.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/445735
Eric Botcazou [Thu, 27 Oct 2022 22:22:43 +0000 (00:22 +0200)]
Aarch64: Do not define DONT_USE_BUILTIN_SETJMP
The setting looks obsolete at this point.
gcc/
* config/aarch64/aarch64.h (DONT_USE_BUILTIN_SETJMP): Delete.
H.J. Lu [Thu, 20 Oct 2022 18:55:19 +0000 (11:55 -0700)]
x86: Replace ne:CCC/ne:CCO with UNSPEC_CC_NE in neg patterns
In i386.md, neg patterns which set MODE_CC register like
(set (reg:CCC FLAGS_REG)
(ne:CCC (match_operand:SWI48 1 "general_reg_operand") (const_int 0)))
can lead to errors when operand 1 is a constant value. If FLAGS_REG in
(set (reg:CCC FLAGS_REG)
(ne:CCC (const_int 2) (const_int 0)))
is set to 1, RTX simplifiers may simplify
(set (reg:SI 93)
(neg:SI (ltu:SI (reg:CCC 17 flags) (const_int 0 [0]))))
as
(set (reg:SI 93)
(neg:SI (ltu:SI (const_int 1) (const_int 0 [0]))))
which leads to incorrect results since LTU on MODE_CC register isn't the
same as "unsigned less than" in x86 backend. To prevent RTL optimizers
from setting MODE_CC register to a constant, use UNSPEC_CC_NE to replace
ne:CCC/ne:CCO when setting FLAGS_REG in neg patterns.
gcc/
PR target/107172
* config/i386/i386.md (UNSPEC_CC_NE): New.
Replace ne:CCC/ne:CCO with UNSPEC_CC_NE in neg patterns.
gcc/testsuite/
PR target/107172
* gcc.target/i386/pr107172.c: New test.
Andrew Pinski [Thu, 27 Oct 2022 04:37:01 +0000 (04:37 +0000)]
Use simple_dce_from_worklist with match_simplify_replacement.
This is a simple patch to do some DCE after a successful
match and simplify replacement in PHI-OPT. match and simplify
likes to generate some extra statements which should be cleaned
up.
OK? Bootstrapped and tested on x86_64-linux with no regressions.
Thanks,
Andrew Pinski
gcc/ChangeLog:
* tree-ssa-phiopt.cc: Include tree-ssa-dce.h
(replace_phi_edge_with_variable):
New argument, dce_ssa_names. Call simple_dce_from_worklist.
(match_simplify_replacement): If we inserted a sequence,
mark the lhs of the new sequence to be possible dce.
Always move the statement and mark the lhs (if it is a name)
as possible to remove.
Jakub Jelinek [Thu, 27 Oct 2022 18:10:18 +0000 (20:10 +0200)]
c++: Fix ICE on g++.dg/modules/adl-3_c.C [PR107379]
As mentioned in the PR, apparently my r13-2887 P1467R9 changes
regressed these tests on powerpc64le-linux with IEEE quad by default.
I believe my changes just uncovered a latent bug.
The problem is that push_namespace calls find_namespace_slot,
which does:
tree *slot = DECL_NAMESPACE_BINDINGS (ns)
->find_slot_with_hash (name, name ? IDENTIFIER_HASH_VALUE (name) : 0,
create_p ? INSERT : NO_INSERT);
In the <identifier_node 0x7fffe9f55ac0 details> ns case, slot is non-NULL
above with a binding_vector in it.
Then pushdecl is called and this does:
slot = find_namespace_slot (ns, name, ns == current_namespace);
where ns == current_namespace (ns is :: and name is details) is true.
So this again calls
tree *slot = DECL_NAMESPACE_BINDINGS (ns)
->find_slot_with_hash (name, name ? IDENTIFIER_HASH_VALUE (name) : 0,
create_p ? INSERT : NO_INSERT);
but this time with create_p and so INSERT.
At this point we reach
if (insert == INSERT && m_size * 3 <= m_n_elements * 4)
expand ();
and when we are unlucky and the occupancy of the hash table just reached 3/4,
expand () is called and the hash table is reallocated. But when that happens,
it means the slot pointer in the pushdecl caller (push_namespace) points to
freed memory and so any accesses to it in make_namespace_finish will be UB.
The following patch fixes it by calling find_namespace_slot again even if it
was non-NULL, just doesn't assert it is *slot == ns in that case (because
it often is not).
2022-10-27 Jakub Jelinek <jakub@redhat.com>
PR c++/107379
* name-lookup.cc (push_namespace): Call find_namespace_slot again
after pushdecl as the hash table might be expanded during pushdecl.
Nathan Sidwell [Mon, 24 Oct 2022 21:39:55 +0000 (17:39 -0400)]
c++: Templated lambda mangling
(Explicitly) Templated lambdas have a different signature to
implicitly templated lambdas -- '[]<template T> (T) {}' is not the
same as '[](auto) {}'. This should be reflected in the mangling. The
ABI captures this as
https://github.com/itanium-cxx-abi/cxx-abi/issues/31, and clang has
implemented such additions.
It's relatively straight forwards to write out the non-synthetic
template parms, and note if we need to issue an ABI warning.
gcc/cp/
* mangle.cc (write_closure_template_head): New.
(write_closure_type_name): Call it.
gcc/testsuite/
* g++.dg/abi/lambda-ctx1-18.C: Adjust.
* g++.dg/abi/lambda-ctx1-18vs17.C: Adjust.
* g++.dg/abi/lambda-tpl1-17.C: New.
* g++.dg/abi/lambda-tpl1-18.C: New.
* g++.dg/abi/lambda-tpl1-18vs17.C: New.
* g++.dg/abi/lambda-tpl1.h: New.
Richard Sandiford [Thu, 27 Oct 2022 13:20:23 +0000 (14:20 +0100)]
aarch64: Reinstate some uses of CONSTEXPR
In
9482a5e4eac8d696129ec2854b331e1bb5dbab42 I'd replaced uses
of CONSTEXPR with direct uses of constexpr. However, it turns
out that we still have CONSTEXPR for a reason: GCC 4.8 doesn't
implement constexpr properly, and for example rejects things like:
extern const int x;
constexpr int x = 1;
This patch partially reverts the previous one. To make things
more complicated, there are still some things that need to be
constexpr rather than CONSTEXPR, since they are used to initialise
scalar constants. The patch therefore doesn't change anything
in aarch64-feature-deps.h.
gcc/
* config/aarch64/aarch64-protos.h: Replace constexpr with
CONSTEXPR.
* config/aarch64/aarch64-sve-builtins-base.cc: Likewise.
* config/aarch64/aarch64-sve-builtins-functions.h: Likewise.
* config/aarch64/aarch64-sve-builtins-shapes.cc: Likewise.
* config/aarch64/aarch64-sve-builtins-sve2.cc: Likewise.
* config/aarch64/aarch64-sve-builtins.cc: Likewise.
* config/aarch64/aarch64.cc: Likewise.
* config/aarch64/driver-aarch64.cc: Likewise
Aldy Hernandez [Tue, 25 Oct 2022 20:44:51 +0000 (22:44 +0200)]
[PR tree-optimization/107394] Canonicalize global franges as they are read back.
The problem here is that we're inlining a global range with NANs into
a function that has been tagged with __attribute__((optimize
("-ffinite-math-only"))). As the global range is copied from
SSA_NAME_RANGE_INFO, its NAN bits are copied, which then cause
frange::verify_range() to fail a sanity check making sure no NANs
creep in when !HONOR_NANS.
I think what we should do is nuke the NAN bits as we're restoring the
global range. For that matter, if we use the frange constructor,
everything except that NAN sign will be done automatically, including
dropping INFs to the min/max representable range when appropriate.
PR tree-optimization/107394
gcc/ChangeLog:
* value-range-storage.cc (frange_storage_slot::get_frange): Use
frange constructor.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/pr107394.c: New test.
Thomas Schwinge [Thu, 31 Mar 2022 10:06:29 +0000 (12:06 +0200)]
options: Clarify 'Init' option property usage for streaming optimization
This clarifies commit
95db7e9afe57ca1c269d46baa2accced004e5c74
"options, lto: Optimize streaming of optimization nodes".
No functional change; no change in generated files.
gcc/
* optc-save-gen.awk: Clarify 'Init' option property usage for
streaming optimization.
Martin Liska [Thu, 27 Oct 2022 08:29:17 +0000 (10:29 +0200)]
lto: do not load LTO stream for aliases [PR107418]
PR lto/107418
gcc/lto/ChangeLog:
* lto-dump.cc (lto_main): Do not load LTO stream for aliases.
Jakub Jelinek [Thu, 27 Oct 2022 08:24:45 +0000 (10:24 +0200)]
c++: Fix excess precision related ICE on invalid binop [PR107382, PR107383]
The following tests ICE in the gcc_assert (common); in cp_build_binary_op.
I've missed that while for * common is set always, while for +, - and /
it is in some cases not.
If it is not, then
if (!result_type
&& arithmetic_types_p
&& (shorten || common || short_compare))
condition is false, then the following
if (may_need_excess_precision
&& (orig_type0 != type0 || orig_type1 != type1)
&& build_type == NULL_TREE)
would fail the assertion there and if there wouldn't be excess precision,
if (code == SPACESHIP_EXPR)
would be false (for SPACESHIP_EXPR we always have build_type set like for
other comparisons) and then trigger
if (!result_type)
{
if (complain & tf_error)
{
binary_op_rich_location richloc (location,
orig_op0, orig_op1, true);
error_at (&richloc,
"invalid operands of types %qT and %qT to binary %qO",
TREE_TYPE (orig_op0), TREE_TYPE (orig_op1), code);
}
return error_mark_node;
}
So, if result_type is NULL, we don't really need to compute
semantic_result_type because nothing will use it anyway and can get
fall through into the error/return error_mark_node; case.
2022-10-27 Jakub Jelinek <jakub@redhat.com>
PR c++/107382
PR c++/107383
* typeck.cc (cp_build_binary_op): Don't compute semantic_result_type
if result_type is NULL.
* g++.dg/diagnostic/bad-binary-ops2.C: New test.
Torbjörn SVENSSON [Tue, 25 Oct 2022 09:45:40 +0000 (11:45 +0200)]
IRA: Make sure array is big enough
In commit
081c96621da, the call to resize_reg_info() was moved before
the call to remove_scratches() and the latter one can increase the
number of regs and that would cause an out of bounds usage on the
reg_renumber global array.
Without this patch, the following testcase randomly fails with:
during RTL pass: ira
In file included from /src/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_y.c:13:
/src/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_y.c: In function 'checkgSf13':
/src/gcc/testsuite/gcc.dg/compat/fp-struct-test-by-value-y.h:28:1: internal compiler error: Segmentation fault
/src/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_y.c:22:1: note: in expansion of macro 'TEST'
gcc/ChangeLog:
* ira.cc: Resize array after reg number increased.
Co-Authored-By: Yvan ROUX <yvan.roux@foss.st.com>
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Jiawei [Thu, 20 Oct 2022 09:32:35 +0000 (17:32 +0800)]
RISC-V: Add zhinx/zhinxmin testcases.
Test zhinx/zhinxmin support, same like with zfh/zfhmin testcases
but use gprs and don't use fmv instruction.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/_Float16-zhinx-1.c: New test.
* gcc.target/riscv/_Float16-zhinx-2.c: New test.
* gcc.target/riscv/_Float16-zhinx-3.c: New test.
* gcc.target/riscv/_Float16-zhinxmin-1.c: New test.
* gcc.target/riscv/_Float16-zhinxmin-2.c: New test.
* gcc.target/riscv/_Float16-zhinxmin-3.c: New test.
Jiawei [Thu, 20 Oct 2022 09:32:34 +0000 (17:32 +0800)]
RISC-V: Limit regs use for z*inx extension.
Limit z*inx abi support with 'ilp32','ilp32e','lp64' only.
Use GPR instead FPR when 'zfinx' enable, Only use even registers
in RV32 when 'zdinx' enable.
Enable FLOAT16 when Zhinx/Zhinxmin enabled.
Co-Authored-By: Sinan Lin <sinan@isrc.iscas.ac.cn>
gcc/ChangeLog:
* config/riscv/constraints.md (TARGET_ZFINX ? GR_REGS): Set GPRS
use while Zfinx is enable.
* config/riscv/riscv.cc (riscv_hard_regno_mode_ok): Limit odd
registers use when Zdinx enable in RV32 cases.
(riscv_option_override): New target enable MASK_FDIV.
(riscv_libgcc_floating_mode_supported_p): New error info when
use incompatible arch&abi.
(riscv_excess_precision): New target enable FLOAT16.
Jiawei [Thu, 20 Oct 2022 09:32:33 +0000 (17:32 +0800)]
RISC-V: Target support for z*inx extension.
Support 'TARGET_ZFINX' with float instruction pattern and builtin function.
Reuse 'TARGET_HADR_FLOAT', 'TARGET_DOUBLE_FLOAT' and 'TARGET_ZHINX' patterns.
gcc/ChangeLog:
* config/riscv/iterators.md (TARGET_ZFINX):New target.
(TARGET_ZDINX): Ditto.
(TARGET_ZHINX): Ditto.
* config/riscv/riscv-builtins.cc (AVAIL): Ditto.
(riscv_atomic_assign_expand_fenv): Ditto.
* config/riscv/riscv-c.cc (riscv_cpu_cpp_builtins): Ditto.
* config/riscv/riscv.md: Ditto.
Jiawei [Thu, 20 Oct 2022 09:32:32 +0000 (17:32 +0800)]
RISC-V: Minimal support of z*inx extension.
Minimal support of z*inx extension, include 'zfinx', 'zdinx' and 'zhinx/zhinxmin'
corresponding to 'f', 'd' and 'zfh/zfhmin', the 'zdinx' will imply 'zfinx'
same as 'd' imply 'f', 'zhinx' will aslo imply 'zfinx', all zfinx extension imply 'zicsr'.
Co-Authored-By: Sinan Lin <sinan@isrc.iscas.ac.cn>
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc: New extensions.
* config/riscv/arch-canonicalize: New imply relations.
* config/riscv/riscv-opts.h (MASK_ZFINX): New mask.
(MASK_ZDINX): Ditto.
(MASK_ZHINX): Ditto.
(MASK_ZHINXMIN): Ditto.
(TARGET_ZFINX): New target.
(TARGET_ZDINX): Ditto.
(TARGET_ZHINX): Ditto.
(TARGET_ZHINXMIN): Ditto.
* config/riscv/riscv.opt: New target variable.
GCC Administrator [Thu, 27 Oct 2022 00:18:35 +0000 (00:18 +0000)]
Daily bump.
David Malcolm [Wed, 26 Oct 2022 20:45:17 +0000 (16:45 -0400)]
analyzer: fixes to file-descriptor handling
gcc/analyzer/ChangeLog:
* sm-fd.cc (fd_state_machine::on_open): Transition to "unchecked"
when the mode is symbolic, rather than just on integer constants.
(fd_state_machine::check_for_open_fd): Don't complain about
unchecked values in the start state.
gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/fd-3.c (test_5): Expect "opened here" message
even when flags are symbolic.
(test_read_from_symbolic_fd): New.
(test_write_to_symbolic_fd): New.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Wed, 26 Oct 2022 20:44:23 +0000 (16:44 -0400)]
analyzer: add sm-fd.dot
Add a .dot file to document the file descriptor state machine.
gcc/analyzer/ChangeLog:
* sm-fd.dot: New file.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Harald Anlauf [Wed, 26 Oct 2022 19:00:44 +0000 (21:00 +0200)]
Fortran: BOZ literal constants are not compatible to any type [PR103413]
gcc/fortran/ChangeLog:
PR fortran/103413
* symbol.cc (gfc_type_compatible): A boz-literal-constant has no type
and thus is not considered compatible to any type.
gcc/testsuite/ChangeLog:
PR fortran/103413
* gfortran.dg/illegal_boz_arg_4.f90: New test.
David Faust [Mon, 24 Oct 2022 20:59:39 +0000 (13:59 -0700)]
bpf: add preserve_field_info builtin
Add BPF __builtin_preserve_field_info. This builtin is used to extract
information to facilitate struct and union relocations performed by the
BPF loader, especially for bitfields.
The builtin has the following signature:
unsigned int __builtin_preserve_field_info (EXPR, unsigned int KIND);
Where EXPR is an expression accessing a field of a struct or union.
Depending on KIND, different information is returned to the program. The
supported values for KIND are as follows:
enum {
FIELD_BYTE_OFFSET = 0,
FIELD_BYTE_SIZE,
FIELD_EXISTENCE,
FIELD_SIGNEDNESS,
FIELD_LSHIFT_U64,
FIELD_RSHIFT_U64
};
If -mco-re is in effect (explicitly or implicitly specified), a CO-RE
relocation is added for the access in EXPR recording the relevant
information according to KIND.
gcc/
* config/bpf/bpf.cc: Support __builtin_preserve_field_info.
(enum bpf_builtins): Add new builtin.
(bpf_init_builtins): Likewise.
(bpf_core_field_info): New function.
(bpf_expand_builtin): Accomodate new builtin. Refactor adding new
relocation to...
(maybe_make_core_relo): ... here. New function.
(bpf_resolve_overloaded_builtin): Accomodate new builtin.
(bpf_core_newdecl): Likewise.
(bpf_core_walk): Likewise.
(bpf_core_is_maybe_aggregate_access): Improve logic.
(struct core_walk_data): New.
* config/bpf/coreout.cc (bpf_core_reloc_add): Allow adding different
relocation kinds.
* config/bpf/coreout.h: Analogous change.
* doc/extend.texi: Document BPF __builtin_preserve_field_info.
gcc/testsuite/
* gcc.target/bpf/core-builtin-fieldinfo-errors-1.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-errors-2.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-existence-1.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-lshift-1-be.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-lshift-1-le.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-lshift-2.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-offset-1.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-rshift-1.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-rshift-2.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-sign-1.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-sign-2.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-size-1.c: New test.
Marek Polacek [Fri, 14 Oct 2022 14:05:57 +0000 (10:05 -0400)]
c++: Implement -Wdangling-reference [PR106393]
This patch implements a new experimental warning (enabled by -Wall) to
detect references bound to temporaries whose lifetime has ended. The
primary motivation is the Note in
<https://en.cppreference.com/w/cpp/algorithm/max>:
Capturing the result of std::max by reference produces a dangling reference
if one of the parameters is a temporary and that parameter is returned:
int n = 1;
const int& r = std::max(n-1, n+1); // r is dangling
That's because both temporaries for n-1 and n+1 are destroyed at the end
of the full expression. With this warning enabled, you'll get:
g.C:3:12: warning: possibly dangling reference to a temporary [-Wdangling-reference]
3 | const int& r = std::max(n-1, n+1);
| ^
g.C:3:24: note: the temporary was destroyed at the end of the full expression 'std::max<int>((n - 1), (n + 1))'
3 | const int& r = std::max(n-1, n+1);
| ~~~~~~~~^~~~~~~~~~
The warning works by checking if a reference is initialized with a function
that returns a reference, and at least one parameter of the function is
a reference that is bound to a temporary. It assumes that such a function
actually returns one of its arguments! (I added code to check_return_expr
to suppress the warning when we've seen the definition of the function
and we can say that it can return a variable with static storage
duration.)
It warns when the function in question is a member function, but only if
the function is invoked on a temporary object, otherwise the warning
would emit loads of warnings for valid code like obj.emplace<T>({0}, 0).
It does detect the dangling reference in:
struct S {
const S& self () { return *this; }
};
const S& s = S().self();
It warns in member initializer lists as well:
const int& f(const int& i) { return i; }
struct S {
const int &r;
S() : r(f(10)) { }
};
I've run the testsuite/bootstrap with the warning enabled by default.
There were just a few FAILs, all of which look like genuine bugs.
A bootstrap with the warning enabled by default passed as well.
When testing a previous version of the patch, there were many FAILs in
libstdc++'s 22_locale/; all of them because the warning triggered on
const test_type& obj = std::use_facet<test_type>(std::locale());
but this code looks valid -- std::use_facet doesn't return a reference
to its parameter. Therefore I added a #pragma and code to suppress the
warning.
PR c++/106393
gcc/c-family/ChangeLog:
* c.opt (Wdangling-reference): New.
gcc/cp/ChangeLog:
* call.cc (expr_represents_temporary_p): New, factored out of...
(conv_binds_ref_to_temporary): ...here. Don't return false just
because a ck_base is missing. Use expr_represents_temporary_p.
(do_warn_dangling_reference): New.
(maybe_warn_dangling_reference): New.
(extend_ref_init_temps): Call maybe_warn_dangling_reference.
* cp-tree.h: Adjust comment.
* typeck.cc (check_return_expr): Suppress -Wdangling-reference
warnings.
gcc/ChangeLog:
* doc/invoke.texi: Document -Wdangling-reference.
libstdc++-v3/ChangeLog:
* include/bits/locale_classes.tcc: Add #pragma to disable
-Wdangling-reference with std::use_facet.
gcc/testsuite/ChangeLog:
* g++.dg/cpp23/elision4.C: Use -Wdangling-reference, add dg-warning.
* g++.dg/cpp23/elision7.C: Likewise.
* g++.dg/warn/Wdangling-pointer-2.C: Use -Wno-dangling-reference.
* g++.dg/warn/Wdangling-reference1.C: New test.
* g++.dg/warn/Wdangling-reference2.C: New test.
* g++.dg/warn/Wdangling-reference3.C: New test.
Takayuki 'January June' Suwa [Wed, 26 Oct 2022 06:27:51 +0000 (15:27 +0900)]
xtensa: Fix out-of-bounds array access in the movdi pattern
The following new warnings were introduced in the commit
4f3f0296acbb ("xtensa: Prepare the transition from Reload to LRA"):
gcc/config/xtensa/xtensa.md:945:26: error: array subscript 3 is above
array bounds of 'rtx_def* [2]' [-Werror=array-bounds]
945 | emit_move_insn (operands[2], operands[3]);
gcc/config/xtensa/xtensa.md:945:26: error: array subscript 2 is above
array bounds of 'rtx_def* [2]' [-Werror=array-bounds]
945 | emit_move_insn (operands[2], operands[3]);
From gcc/insn-emit.cc (generated by building):
> /* ../../gcc/config/xtensa/xtensa.md:932 */
> rtx
> gen_movdi (rtx operand0,
> rtx operand1)
> {
> rtx_insn *_val = 0;
> start_sequence ();
> {
> rtx operands[2]; // only 2 elements
> operands[0] = operand0;
> operands[1] = operand1;
> #define FAIL return (end_sequence (), _val)
> #define DONE return (_val = get_insns (), end_sequence (), _val)
> #line 936 "../../gcc/config/xtensa/xtensa.md"
> {
> if (CONSTANT_P (operands[1]))
> {
> /* Split in halves if 64-bit Const-to-Reg moves
> because of offering further optimization opportunities. */
> if (register_operand (operands[0], DImode))
> {
> xtensa_split_DI_reg_imm (operands); // out-of-bounds!
> emit_move_insn (operands[0], operands[1]);
> emit_move_insn (operands[2], operands[3]); // out-of-bounds!
> DONE;
> }
gcc/ChangeLog:
* config/xtensa/xtensa.md (movdi):
Copy operands[0...1] to ops[0...3] and then use the latter before
calling xtensa_split_DI_reg_imm() and emitting insns.
Alexander Monakov [Wed, 26 Oct 2022 13:37:34 +0000 (16:37 +0300)]
ipa-visibility: remove assert in TLS optimization [PR107353]
When upgrading TLS access model based on optimized symbol visibility
status, we attempted to assert that recomputing the model would not
weaken it. It turns out that C, C++, and Fortran front-ends all can
(unintentionally) assign a stronger model than what can be derived
from the declaration.
Let's act conservatively instead of asserting, at least as long as
such pre-existing issues remain.
gcc/ChangeLog:
PR other/107353
* ipa-visibility.cc (function_and_variable_visibility):
Conditionally upgrade TLS model instead of asserting.
Andrew MacLeod [Tue, 25 Oct 2022 19:16:47 +0000 (15:16 -0400)]
Check if varying may also be non-negative.
When using strict enums, we can sometimes turn varying into a better
range.
* gimple-range-fold.cc (fold_using_range::fold_stmt): Check if
stmt is non-negative and adjust the range.
Martin Liska [Tue, 25 Oct 2022 04:28:44 +0000 (06:28 +0200)]
i386: add reset_cpu_feature
gcc/ChangeLog:
* common/config/i386/cpuinfo.h (has_cpu_feature): Add comment.
(reset_cpu_feature): New.
(get_zhaoxin_cpu): Use reset_cpu_feature.
Ju-Zhe Zhong [Tue, 25 Oct 2022 13:53:23 +0000 (21:53 +0800)]
RISC-V: Fix epilogue generation for barrier.
I noticed that I have made a mistake in previous patch:
https://patchwork.sourceware.org/project/gcc/patch/
20220817071950.271762-1-juzhe.zhong@rivai.ai/
The previous statement before this patch:
bool need_barrier_p = (get_frame_size () + cfun->machine->frame.arg_pointer_offset) != 0;
However, I changed it in the previous patch:
bool need_barrier_p = known_ne (get_frame_size (), cfun->machine->frame.arg_pointer_offset);
This is incorrect.
Now, I correct this statement in this patch.
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_expand_epilogue): Fix statement.
Ju-Zhe Zhong [Tue, 25 Oct 2022 03:22:38 +0000 (11:22 +0800)]
RISC-V: ADJUST_NUNITS according to -march.
This patch fixed PR107357: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107357
gcc/ChangeLog:
PR target/107357
* config/riscv/riscv-modes.def (VECTOR_BOOL_MODE): Set to minimum size.
(ADJUST_NUNITS): Adjust according to -march.
(ADJUST_BYTESIZE): Ditto.
* config/riscv/riscv-protos.h (riscv_v_ext_enabled_vector_mode_p):
Remove.
(riscv_v_ext_vector_mode_p): Change function implementation.
* config/riscv/riscv-vector-builtins.cc (rvv_switcher::rvv_switcher):
Change to riscv_v_ext_vector_mode_p.
(register_builtin_type): Ditto.
* config/riscv/riscv.cc (riscv_v_ext_vector_mode_p): Change to enabled
modes.
(ENTRY): Ditto.
(riscv_v_ext_enabled_vector_mode_p): Remove.
(riscv_v_adjust_nunits): New function.
(riscv_vector_mode_supported_p): Use riscv_v_ext_vector_mode_p instead.
* config/riscv/riscv.h (riscv_v_adjust_nunits): New function.
Ju-Zhe Zhong [Mon, 24 Oct 2022 02:08:53 +0000 (10:08 +0800)]
RISC-V: Support load/store in mov<mode> pattern for RVV modes.
gcc/ChangeLog:
* config.gcc (riscv*): Add riscv-v.o to extra_objs.
* config/riscv/constraints.md (vu): New constraint.
(vi): Ditto.
(Wc0): Ditto.
(Wc1): Ditto.
* config/riscv/predicates.md (vector_length_operand): New.
(reg_or_mem_operand): Ditto.
(vector_move_operand): Ditto.
(vector_mask_operand): Ditto.
(vector_merge_operand): Ditto.
* config/riscv/riscv-protos.h (riscv_regmode_natural_size) New.
(riscv_vector::const_vec_all_same_in_range_p): Ditto.
(riscv_vector::legitimize_move): Ditto.
(tail_policy): Ditto.
(mask_policy): Ditto.
* config/riscv/riscv-v.cc: New.
* config/riscv/riscv-vector-builtins-bases.cc
(vsetvl::expand): Refactor how LMUL encoding.
* config/riscv/riscv.cc (riscv_print_operand): Update how LMUL
print and mask operand print.
(riscv_regmode_natural_size): New.
* config/riscv/riscv.h (REGMODE_NATURAL_SIZE): New.
* config/riscv/riscv.md (mode): Add vector modes.
* config/riscv/t-riscv (riscv-v.o) New.
* config/riscv/vector-iterators.md: New.
* config/riscv/vector.md (vundefined<mode>): New.
(mov<mode>): New.
(*mov<mode>): New.
(@vsetvl<mode>_no_side_effects): New.
(@pred_mov<mode>): New.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/base/mov-1.c: New.
* gcc.target/riscv/rvv/base/mov-10.c: New.
* gcc.target/riscv/rvv/base/mov-11.c: New.
* gcc.target/riscv/rvv/base/mov-12.c: New.
* gcc.target/riscv/rvv/base/mov-13.c: New.
* gcc.target/riscv/rvv/base/mov-2.c: New.
* gcc.target/riscv/rvv/base/mov-3.c: New.
* gcc.target/riscv/rvv/base/mov-4.c: New.
* gcc.target/riscv/rvv/base/mov-5.c: New.
* gcc.target/riscv/rvv/base/mov-6.c: New.
* gcc.target/riscv/rvv/base/mov-7.c: New.
* gcc.target/riscv/rvv/base/mov-8.c: New.
* gcc.target/riscv/rvv/base/mov-9.c: New.
Monk Chiang [Tue, 25 Oct 2022 06:17:33 +0000 (14:17 +0800)]
RISC-V: Recognized Svinval and Svnapot extensions
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc (riscv_ext_version_table):
Add svinval and svnapot extension.
(riscv_ext_flag_table): Ditto.
* config/riscv/riscv-opts.h (MASK_SVINVAL): New.
(MASK_SVNAPOT): Ditto.
(TARGET_SVINVAL): Ditto.
(TARGET_SVNAPOT): Ditto.
* config/riscv/riscv.opt (riscv_sv_subext): New.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/predef-24.c:New.
* gcc.target/riscv/predef-25.c:New.
Ju-Zhe Zhong [Mon, 24 Oct 2022 14:24:14 +0000 (22:24 +0800)]
RISC-V: Adjust table indentation in commnet for riscv-modes.def
gcc/ChangeLog:
* config/riscv/riscv-modes.def: Adjust table indentation in commnet.
Martin Liska [Wed, 26 Oct 2022 06:39:49 +0000 (08:39 +0200)]
gcc/configure: regenerate
gcc/ChangeLog:
* configure: Regenerate.
Aldy Hernandez [Tue, 25 Oct 2022 20:22:56 +0000 (22:22 +0200)]
Convert flag_finite_math_only uses in frange to HONOR_*.
As mentioned earlier, we should be using HONOR_* on types rather than
flag_finite_math_only.
gcc/ChangeLog:
* value-range.cc (frange::set): Use HONOR_*.
(frange::verify_range): Same.
* value-range.h (frange_val_min): Same.
(frange_val_max): Same.
Jiufu Guo [Tue, 19 Jul 2022 10:30:58 +0000 (18:30 +0800)]
rs6000: cannot_force_const_mem for HIGH code rtx[PR106460]
As the issue in PR106460, a rtx 'high:DI (symbol_ref:DI ("var_48")' is tried
to store into constant pool and ICE occur. But actually, this rtx represents
partial incomplete address and can not be put into a .rodata section.
This patch updates rs6000_cannot_force_const_mem to return true for rtx(s) with
HIGH code, because these rtx(s) indicate part of address and are not ok for
constant pool.
Below are some examples:
(high:DI (const:DI (plus:DI (symbol_ref:DI ("xx") (const_int 12 [0xc])))))
(high:DI (symbol_ref:DI ("var_1")..)))
PR target/106460
gcc/ChangeLog:
* config/rs6000/rs6000.cc (rs6000_cannot_force_const_mem): Return true
for HIGH code rtx.
gcc/testsuite/ChangeLog:
* gcc.target/powerpc/pr106460.c: New test.
Kito Cheng [Fri, 14 Oct 2022 09:34:02 +0000 (17:34 +0800)]
RISC-V: Add h extension support
`h` was the prefix of multi-letter extension name, but it become a
extension in later RISC-V isa spec.
Fortunately we don't have any extension really defined is prefixed
with `h`, so we can just change that.
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc (riscv_ext_version_table):
Add `h`.
(riscv_supported_std_ext): Ditto.
(multi_letter_subset_rank): Remove `h`.
(riscv_subset_list::parse_std_ext): Handle `h` as single letter
extension.
(riscv_subset_list::parse): Ditto.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/arch-18.c: New.
* gcc.target/riscv/arch-5.c: Remove test for prefixed
with `h`.
* gcc.target/riscv/predef-23.c: New.
Eugene Rozenfeld [Wed, 26 Oct 2022 00:17:05 +0000 (17:17 -0700)]
Don't force DWARF4 for AutoFDO tests
Support for DWARF5 was added to create_gcov in
https://github.com/google/autofdo so we no longer need
to force DWARF4 for AutoFDO tests.
Tested on x86_64-pc-linux-gnu.
gcc/testsuite/ChangeLog:
* lib/profopt.exp: Don't force DWARF4 for AutoFDO tests
GCC Administrator [Wed, 26 Oct 2022 00:17:15 +0000 (00:17 +0000)]
Daily bump.
Eugene Rozenfeld [Mon, 25 Apr 2022 18:45:43 +0000 (11:45 -0700)]
Start using discriminators in AutoFDO.
Tested on x86_64-pc-linux-gnu.
gcc/ChangeLog:
* auto-profile.cc (get_combined_location): Include discriminator in the
returned combined location.
(read_function_instance): Read discriminators from profiles.
Nathan Sidwell [Tue, 25 Oct 2022 13:39:00 +0000 (09:39 -0400)]
c++: Adjust synthetic template parm creation
We intend to mark synthetic template parameters (coming from use of auto
parms), as DECL_VIRTUAL_P. The API of process_template_parm is
awkwardly confusing, and we were marking the previous template parm
(unless this was the first parm). process_template_parm returns the list
of parms, when most (all?) users really want the newly-added final node.
That's a bigger change, so let's not do it right now. With this, we
correctly mark such synthetic parms DECL_VIRTUAL_P.
gcc/cp/
* parser.cc (synthesize_implicit_template_parm): Fix thinko about
mark the new parm DECL_VIRTUAL_P. Avoid unneccessary tree_last call.
Patrick Palka [Tue, 25 Oct 2022 18:14:29 +0000 (14:14 -0400)]
c++: remove use_default_args parm of coerce_template_parms
The parameter use_default_args of coerce_template_parms, introduced way
back in r110693, is effectively unused ever since r7-5536-g3c75aaa3d884ef
removed the last 'coerce_template_parms (..., true, false)' call. So
this patch aims to simplify this function's API by getting rid of this
parameter.
In passing, I noticed we currently define wrapper overloads of
coerce_template_parms that act as defacto default arguments for complain
and require_all_args. It seems cleaner however to just specify real
default arguments for the main overload instead. And I suppose we
should also give c_innermost_t_p the same defaults.
But I'm not sure about defaulting complain to tf_none, which is
inconsistent with how we default it in other places to either tf_error
or tf_warning_or_error (as a convenience for non-SFINAE callers). And
since in general it's probably better to not default complain as that's
a source of SFINAE bugs, and only a handful of callers use this defacto
complain=tf_none default, this patch gets rid of this complain default
(but keeps the require_all_args default).
gcc/cp/ChangeLog:
* constraint.cc (resolve_function_concept_overload): Explicitly
pass complain=tf_none to coerce_template_parms.
(resolve_concept_check): Likewise.
(normalize_concept_check): Likewise.
* cp-tree.h (coerce_template_parms): Declare the main overload
and default its last parameter to true. Remove wrapper overloads.
* pt.cc (determine_specialization): Adjust calls to
coerce_template_parms and coerce_innermost_template_parms after
removing their last parameter.
(coerce_template_args_for_ttp): Likewise.
(coerce_ttp_args_for_tta): Likewise.
(coerce_template_template_parms): Likewise.
(coerce_template_parms): Remove use_default_args parameter and
adjust function comment. Document default argument. Remove
wrapper overloads. No longer static.
(coerce_innermost_template_parms): Remove use_default_args
parameter. Default require_all_args to true.
(lookup_template_class): As with determine_specialization.
(finish_template_variable): Likewise.
(tsubst_decl): Likewise.
(instantiate_alias_template): Likewise.
(fn_type_unification): Likewise.
(resolve_overloaded_unification): Likewise.
(resolve_nondeduced_context): Likewise.
(get_partial_spec_bindings): Likewise.
Jason Merrill [Tue, 25 Oct 2022 17:54:12 +0000 (13:54 -0400)]
c++: correct fold_operand change
Still want the conversion to bool.
gcc/cp/ChangeLog:
* constexpr.cc (find_failing_clause_r): Re-add the call to
contextual_conv_bool.
Patrick Palka [Tue, 25 Oct 2022 17:41:18 +0000 (13:41 -0400)]
c++ modules: enum TYPE_MIN/MAX_VALUE streaming [PR106848]
In the frontend, the TYPE_MIN/MAX_VALUE of ENUMERAL_TYPE is the same as
that of the enum's underlying type (see start_enum). And the underlying
type of an enum is always known, even for an opaque enum that lacks a
definition.
But currently, we stream TYPE_MIN/MAX_VALUE of an enum only as part of
its definition. So if the enum is declared but never defined, the
ENUMERAL_TYPE we stream in will have empty TYPE_MIN/MAX_VALUE fields
despite these fields being non-empty on stream out.
And even if the enum is defined, read_enum_def updates these fields only
on the main variant of the enum type, so for other variants (that we may
have streamed in earlier) these fields remain empty. That these fields
are unexpectedly empty for some ENUMERAL_TYPEs is ultimately the cause
of the below two PRs.
This patch fixes this by making us stream TYPE_MIN/MAX_VALUE directly
for each ENUMERAL_TYPE rather than as part of the enum's definition, so
that we naturally also stream these fields for opaque enums (and each
enum type variant).
PR c++/106848
PR c++/102600
gcc/cp/ChangeLog:
* module.cc (trees_out::core_vals): Stream TYPE_MAX_VALUE and
TYPE_MIN_VALUE of ENUMERAL_TYPE.
(trees_in::core_vals): Likewise.
(trees_out::write_enum_def): Don't stream them here.
(trees_in::read_enum_def): Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/modules/enum-9_a.H: New test.
* g++.dg/modules/enum-9_b.C: New test.
* g++.dg/modules/enum-10_a.H: New test.
* g++.dg/modules/enum-10_b.C: New test.
* g++.dg/modules/enum-11_a.H: New test.
* g++.dg/modules/enum-11_b.C: New test.
H.J. Lu [Wed, 19 Oct 2022 19:53:35 +0000 (12:53 -0700)]
Always use TYPE_MODE instead of DECL_MODE for vector field
e034c5c8957 re PR target/78643 (ICE in convert_move, at expr.c:230)
fixed the case where DECL_MODE of a vector field is BLKmode and its
TYPE_MODE is a vector mode because of target attribute. Remove the
BLKmode check for the case where DECL_MODE of a vector field is a vector
mode and its TYPE_MODE isn't a vector mode because of target attribute.
gcc/
PR target/107304
* expr.cc (get_inner_reference): Always use TYPE_MODE for vector
field with vector raw mode.
gcc/testsuite/
PR target/107304
* gcc.target/i386/pr107304.c: New test.
Jason Merrill [Tue, 25 Oct 2022 00:36:32 +0000 (20:36 -0400)]
c++: constexpr-evaluate more assumes
The initial [[assume]] support avoided evaluating assumes with
TREE_SIDE_EFFECTS set, such as calls, because we don't want any side-effects
that change the constexpr state. This patch allows us to evaluate
expressions with that flag set by tracking which variables the evaluation is
allowed to modify, and giving up if it tries to touch any others.
I considered allowing changes to other variables and then rolling them back,
but that seems like a rare enough situation that it doesn't seem worth
working to handle nicely at this point.
gcc/cp/ChangeLog:
* constexpr.cc (class constexpr_global_ctx): Add modifiable field,
get_value, get_value_ptr, put_value, remove_value, flush_modifiable
member functions.
(class modifiable_tracker): New.
(cxx_eval_internal_function): Use it.
(diagnose_failing_condition): Strip CLEANUP_POINT_EXPR.
gcc/testsuite/ChangeLog:
* g++.dg/cpp23/attr-assume9.C: New test.
* g++.dg/cpp23/attr-assume10.C: New test.
Jason Merrill [Mon, 24 Oct 2022 21:17:24 +0000 (17:17 -0400)]
c++: improve failed constexpr assume diagnostic
I noticed that we were printing "the comparison reduces to (x == 42)" when
we should be able to give the value of x. Fixed by doing the same
evaluation in diagnose_failing_condition that we already do in
find_failing_clause.
gcc/cp/ChangeLog:
* constexpr.cc (fold_operand): New function.
(find_failing_clause_r): Add const.
(find_failing_clause): Add const.
(diagnose_failing_condition): Add ctx parameter.
(cxx_eval_internal_function): Pass it.
* semantics.cc (diagnose_failing_condition): Move to constexpr.cc.
* cp-tree.h: Adjust.
gcc/testsuite/ChangeLog:
* g++.dg/cpp23/attr-assume2.C: Expect constant values.
Segher Boessenkool [Mon, 24 Oct 2022 18:17:24 +0000 (18:17 +0000)]
rs6000: Add CCANY; replace <un>signed by <mode:CCANY>
This is in preparation for adding CCFP, and maybe CCEQ, and whatever
other CC mode we may want later. CCANY is used for CC mode consumers
that actually can take any of the four CR field bits.
2022-10-25 Segher Boessenkool <segher@kernel.crashing.org>
* config/rs6000/rs6000.md (CCEITHER): Delete.
(CCANY): New.
(un): Delete.
(isel_<un>signed_<GPR:mode>): Rename to...
(isel_<CCANY:mode>_<GPR:mode>): ... this. Adjust.
(*isel_reversed_<un>signed_<GPR:mode>): Rename to...
(*isel_reversed_<CCANY:mode>_<GPR:mode>): ... this. Adjust.
(setbc_<un>signed_<GPR:mode>): Rename to...
(setbc_<CCANY:mode>_<GPR:mode>C): ... this. Adjust."
(*setbcr_<un>signed_<GPR:mode>): Rename to ...
(*setbcr_<CCANY:mode>_<GPR:mode>): ... this. Adjust.
(*setnbc_<un>signed_<GPR:mode>): Rename to ...
(*setnbc_<CCANY:mode>_<GPR:mode>): ... this. Adjust.
(*setnbcr_<un>signed_<GPR:mode>): Rename to ...
(*setnbcr_<CCANY:mode>_<GPR:mode>): ... this. Adjust.
(eq<mode>3 for GPR): Adjust.
(ne<mode>3 for GPR): Adjust.
* config/rs6000/rs6000-string.cc (do_isel): Adjust.
* config/rs6000/rs6000.cc (rs6000_emit_int_cmove): Adjust.
Richard Biener [Mon, 24 Oct 2022 06:52:12 +0000 (08:52 +0200)]
tree-optimization/107176 - SCEV analysis association issue
The following fixes a wrong-code issue caused by SCEV analysis
associating an addition due trying to use tail-recursion in
follow_ssa_edge_expr. That causes us to apply a conversion at
the wrong point and thus miscompute the scalar evolution of
an induction variable. This reverts the PR66375 fix and
revisits the PR42512 fix by keeping the evolution symbolic
up to the point we process the first linear function when
we then can check for the supported cases and substitute the
whole symbolic expression with the built chrec substituting
the proper initial value.
To simplify passing around things and to clarify scoping of
the involved functions this change wraps the SCEV DFS walking
code into a class.
PR tree-optimization/107176
PR tree-optimization/66375
PR tree-optimization/42512
* tree-scalar-evolution.cc (follow_ssa_edge_expr): Revert
the PR66375 fix, do not not associate PLUS_EXPR to be able
to use tail-recursion.
(follow_ssa_edge_binary): Likewise.
(interpret_loop_phi): Revert PR42512 fix, do not throw
away analyze_evolution_in_loop result after the fact.
(follow_ssa_edge_expr): When reaching halting_phi initalize
the evolution to the symbolic value of the PHI result.
(add_to_evolution_1): When adding the first evolution verify
we can handle the expression wrapping the symbolic evolution
and replace that in full using the initial condition.
(class scev_dfs): New, contains ...
(follow_ssa_edge_expr, follow_ssa_edge_binary,
follow_ssa_edge_in_condition_phi_branch,
follow_ssa_edge_in_condition_phi,
follow_ssa_edge_inner_loop_phi,
add_to_evolution, add_to_evolution_1): ... these with
loop and halting_phi arguments in class data.
(scev_dfs::get_ev): New toplevel DFS entry, start with
a chrec_dont_know evolution.
(analyze_evolution_in_loop): Use scev_dfs.
* gcc.dg/torture/pr107176.c: New testcase.
Eric Botcazou [Tue, 25 Oct 2022 10:20:33 +0000 (12:20 +0200)]
Relax assertion in profiler
This assertion in branch_prob:
if (bb == ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb)
{
location_t loc = DECL_SOURCE_LOCATION (current_function_decl);
gcc_checking_assert (!RESERVED_LOCATION_P (loc));
had been correct until the fix for PR debug/101598 was installed.
gcc/
* profile.cc (branch_prob): Be prepared for ignored functions with
DECL_SOURCE_LOCATION set to UNKNOWN_LOCATION.
gcc/testsuite:
* gnat.dg/specs/coverage1.ads: New test.
* gnat.dg/specs/variant_part.ads: Minor tweak.
* gnat.dg/specs/weak1.ads: Add dg directive.
Richard Biener [Tue, 25 Oct 2022 08:04:56 +0000 (10:04 +0200)]
Move NOP stripping in SCEV analysis
The following moves a pair of STRIP_USELESS_TYPE_CONVERSIONS to
where it belongs and adds a comment on why we handle GENERIC
there at all.
* tree-scalar-evolution.cc (follow_ssa_edge_expr): Move
STRIP_USELESS_TYPE_CONVERSIONS to where it matters.
Tejas Joshi [Fri, 21 Oct 2022 15:35:39 +0000 (21:05 +0530)]
Remove znver4 instruction reservations
This reverts the changes made to znver.md in:
commit
bf3b532b524ecacb3202ab2c8af419ffaaab7cff
2022-10-21 Tejas Joshi <TejasSanjay.Joshi@amd.com>
gcc/ChangeLog:
* common/config/i386/i386-common.cc (processor_alias_table): Use
CPU_ZNVER3 for znver4.
* config/i386/znver.md: Remove znver4 reservations.
Jakub Jelinek [Tue, 25 Oct 2022 08:45:29 +0000 (10:45 +0200)]
gimplify: Fix comment typos
While looking at gimple_boolify for PR107368, I've noticed 2 comment
typos.
2022-10-25 Jakub Jelinek <jakub@redhat.com>
* gimplify.cc (gimple_boolify): Fix comment typos, prduce -> produce
and There -> These.
Jakub Jelinek [Tue, 25 Oct 2022 08:42:59 +0000 (10:42 +0200)]
gimplify: Call gimple_boolify on IFN_ASSUME argument [PR107368]
The following testcase ICEs in C, because assume attribute condition
has int type rather than bool and the gimplification into GIMPLE_ASSUME
assigns it into a bool variable.
Fixed by calling gimple_boolify.
2022-10-25 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/107368
* gimplify.cc (gimplify_call_expr): For complex IFN_ASSUME
conditions call gimple_boolify on the condition.
* gcc.dg/attr-assume-5.c: New test.
YunQiang Su [Sat, 8 May 2021 09:45:54 +0000 (05:45 -0400)]
MIPS: add builtime option for -mcompact-branches
For R6+ target, it allows to configure gcc to use compact branches only
if avaiable.
gcc/ChangeLog:
* config.gcc: add -with-compact-branches=policy build option.
* doc/install.texi: Likewise.
* config/mips/mips.h: Likewise.
YunQiang Su [Sat, 8 May 2021 09:45:53 +0000 (05:45 -0400)]
MIPS: Not trigger error for pre-R6 and -mcompact-branches=always
For MIPSr6, we may wish to use compact-branches only.
Currently, we have to use `always' option, while it is mark as conflict
with pre-R6.
cc1: error: unsupported combination: ‘mips32r2’ -mcompact-branches=always
Just ignore -mcompact-branches=always for pre-R6.
This patch also defines
__mips_compact_branches_never
__mips_compact_branches_always
__mips_compact_branches_optimal
predefined macros
gcc/ChangeLog:
* config/mips/mips.cc (mips_option_override): not trigger error
for compact-branches=always for pre-R6.
* config/mips/mips.h (TARGET_RTP_PIC): not trigger error for
compact-branches=always for pre-R6.
(TARGET_CB_NEVER): Likewise.
(TARGET_CB_ALWAYS): Likewise.
(struct mips_cpu_info): define macros for compact branch policy.
* doc/invoke.texi: Document "always" with pre-R6.
gcc/testsuite/ChangeLog:
* gcc.target/mips/compact-branches-1.c: add isa_rev>=6.
* gcc.target/mips/mips.exp: don't add -mipsXXr6 option for
-mcompact-branches=always. It is usable for pre-R6 now.
* gcc.target/mips/compact-branches-8.c: New test.
* gcc.target/mips/compact-branches-9.c: New test.
Jakub Jelinek [Tue, 25 Oct 2022 08:39:20 +0000 (10:39 +0200)]
gimplify: Don't add GIMPLE_ASSUME if errors were seen [PR107369]
The FEs emit errors about jumps into assume attribute conditions,
but when we add GIMPLE_ASSUME for the condition which is reachable
through those jumps, we can run into cfg verification diagnostics.
Fixed by throwing the IFN_ASSUME away during gimplification if
seen_error () - like we already do for -O0. GIMPLE_ASSUME in the middle-end
is a pure optimization thing and if errors were reported, the optimizations
will not be beneficial for anything.
2022-10-25 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/107369
* gimplify.cc (gimplify_call_expr): If seen_error, handle complex
IFN_ASSUME the same as for -O0.
* gcc.dg/attr-assume-4.c: New test.
* g++.dg/cpp23/attr-assume8.C: New test.
YunQiang Su [Wed, 21 Sep 2022 11:13:03 +0000 (11:13 +0000)]
MIPS: fix building on multiarch platform
On platforms that support multiarch, such as Debian,
the filesystem hierarchy doesn't fellow the old Irix style:
lib & lib/<multiarch> for native
lib64 for N64 on N32/O32 systems
lib32 for N32 on N64/O32 systems
libo32 for O32 on N64/N32 systems
Thus we cannot
#define STANDARD_STARTFILE_PREFIX_1
#define STANDARD_STARTFILE_PREFIX_2
on N32 or N64 systems, else collect2 won't look for libraries
on /lib/<multiarch>.
gcc/ChangeLog:
* configure.ac: AC_DEFINE(ENABLE_MULTIARCH, 1)
* configure: Regenerated.
* config.in: Regenerated.
* config/mips/mips.h: don't define STANDARD_STARTFILE_PREFIX_1
if ENABLE_MULTIARCH is defined.
* config/mips/t-linux64: define correct multiarch path when
multiarch is enabled.
Richard Biener [Mon, 24 Oct 2022 07:51:32 +0000 (09:51 +0200)]
tree-optimization/100756 - niter analysis and folding
niter analysis, specifically the part trying to simplify the computed
maybe_zero condition against the loop header copying condition, is
confused by us now simplifying
_15 = n_8(D) * 4;
if (_15 > 0)
to
_15 = n_8(D) * 4;
if (n_8(D) > 0)
which is perfectly sound at the point we do this transform. One
solution might be to involve ranger in this simplification, another
is to be more aggressive when expanding expressions - the condition
we try to simplify is _15 > 0, so all we need is expanding that
to n_8(D) * 4 > 0.
The following does just that.
PR tree-optimization/100756
* tree-ssa-loop-niter.cc (expand_simple_operations): Also
expand multiplications by invariants.
* gcc.dg/vect/pr100756.c: New testcase.
Kewen Lin [Tue, 25 Oct 2022 05:18:45 +0000 (00:18 -0500)]
rs6000/test: Support vect_long_long effective target
Currently effective target vect_long_long doesn't have
power specific check, I think it's an oversight. This
is to add the support which checks for has_arch_pwr8,
since we set rs6000_vector_unit[V2DImode] as:
(TARGET_P8_VECTOR) ? VECTOR_P8_VECTOR : VECTOR_NONE;
it means its full support starts from ISA 2.07.
Although ISA 2.06 has some instructions like lxvd2x
and stxvd2x etc., it's used for testing, checking for
ISA 2.07 is more sensitive.
gcc/testsuite/ChangeLog:
* lib/target-supports.exp (check_effective_target_vect_long_long): Add
support for powerpc*-*-*.
Kewen Lin [Tue, 25 Oct 2022 05:18:08 +0000 (00:18 -0500)]
vect: Fix wrong shift_n after widening on BE [PR107338]
As PR107338 shows, with the use of widening loads, the
container_type can become a wider type, it causes us to
get wrong shift_n since the BIT_FIELD_REF offset actually
becomes bigger on BE. Taking the case in PR107338 as
example, at the beginning the container type is short and
BIT_FIELD_REF offset is 8 and size is 4, with unpacking to
wider type int, the high 16 bits are zero, by viewing it
as type int, its offset actually becomes to 24. So the
shift_n should be 4 (32 - 24 - 4) instead of 20 (32 - 8
- 4).
I noticed that if we move shift_n calculation early
before the adjustments for widening loads (container type
change), it's based on all the stuffs of the original
container, the shfit_n calculated there is exactly what
we want, it can be independent of widening. Besides, I
add prec adjustment together with the current adjustments
for widening loads, although prec's subsequent uses don't
require this change for now, since the container type gets
changed, we should keep the corresponding prec consistent.
PR tree-optimization/107338
gcc/ChangeLog:
* tree-vect-patterns.cc (vect_recog_bitfield_ref_pattern): Move
shfit_n calculation before the adjustments for widening loads.
Martin Liska [Tue, 25 Oct 2022 04:58:17 +0000 (06:58 +0200)]
riscv: fix cross compiler
Move riscv_get_valid_option_values out of
Fixes:
riscv/riscv-common.cc:1748:40: error: ‘riscv_get_valid_option_values’ was not declared in this scope
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc
(riscv_get_valid_option_values): Get out of ifdef.
Martin Liska [Tue, 25 Oct 2022 04:16:03 +0000 (06:16 +0200)]
i386: fix pedantic warning
PR target/107364
gcc/ChangeLog:
* common/config/i386/i386-cpuinfo.h (enum processor_vendor):
Fix pedantic warning.
GCC Administrator [Tue, 25 Oct 2022 00:17:33 +0000 (00:17 +0000)]
Daily bump.
David Malcolm [Mon, 24 Oct 2022 20:41:09 +0000 (16:41 -0400)]
analyzer: fix ICE on va_copy [PR107349]
gcc/analyzer/ChangeLog:
PR analyzer/107349
* varargs.cc (get_va_copy_arg): Fix the non-pointer case.
gcc/testsuite/ChangeLog:
PR analyzer/107349
* gcc.dg/analyzer/stdarg-1-ms_abi.c (pr107349): New.
* gcc.dg/analyzer/stdarg-1-sysv_abi.c (pr107349): New.
* gcc.dg/analyzer/stdarg-1.c (pr107349): New.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Martin Liska [Mon, 24 Oct 2022 20:40:00 +0000 (16:40 -0400)]
diagnostics: fix ICE in sarif output with NULL filename [PR107366]
gcc/ChangeLog:
PR analyzer/107366
* diagnostic-format-sarif.cc
(sarif_builder::maybe_make_physical_location_object): Gracefully
reject locations with NULL filename.
gcc/testsuite/ChangeLog:
PR analyzer/107366
* gcc.dg/analyzer/sarif-pr107366.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Mon, 24 Oct 2022 20:38:23 +0000 (16:38 -0400)]
analyzer: handle (NULL == &VAR) [PR107345]
gcc/analyzer/ChangeLog:
PR analyzer/107345
* region-model.cc (region_model::eval_condition_without_cm):
Ensure that constants are on the right-hand side before checking
for them.
gcc/testsuite/ChangeLog:
PR analyzer/107345
* gcc.dg/analyzer/pr107345.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Mon, 24 Oct 2022 20:38:23 +0000 (16:38 -0400)]
analyzer: simplify sm_state_map lookup
gcc/analyzer/ChangeLog:
* engine.cc (impl_region_model_context::get_malloc_map): Replace
with...
(impl_region_model_context::get_state_map_by_name): ...this.
(impl_region_model_context::get_fd_map): Delete.
(impl_region_model_context::get_taint_map): Delete.
* exploded-graph.h (impl_region_model_context::get_fd_map):
Delete.
(impl_region_model_context::get_malloc_map): Delete.
(impl_region_model_context::get_taint_map): Delete.
(impl_region_model_context::get_state_map_by_name): New.
* region-model.h (region_model_context::get_state_map_by_name):
New vfunc.
(region_model_context::get_fd_map): Convert from vfunc to
function.
(region_model_context::get_malloc_map): Likewise.
(region_model_context::get_taint_map): Likewise.
(noop_region_model_context::get_state_map_by_name): New.
(noop_region_model_context::get_fd_map): Delete.
(noop_region_model_context::get_malloc_map): Delete.
(noop_region_model_context::get_taint_map): Delete.
(region_model_context_decorator::get_state_map_by_name): New.
(region_model_context_decorator::get_fd_map): Delete.
(region_model_context_decorator::get_malloc_map): Delete.
(region_model_context_decorator::get_taint_map): Delete.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Mon, 24 Oct 2022 20:38:22 +0000 (16:38 -0400)]
analyzer: handle "pipe" and "pipe2" [PR106300]
gcc/analyzer/ChangeLog:
PR analyzer/106300
* engine.cc (impl_region_model_context::get_fd_map): New.
* exploded-graph.h (impl_region_model_context::get_fd_map): New
decl.
* region-model-impl-calls.cc (region_model::impl_call_pipe): New.
* region-model.cc (region_model::update_for_int_cst_return): New,
based on...
(region_model::update_for_zero_return): ...this. Reimplement in
terms of the former.
(region_model::on_call_pre): Handle "pipe" and "pipe2".
(region_model::on_call_post): Likewise.
* region-model.h (region_model::impl_call_pipe): New decl.
(region_model::update_for_int_cst_return): New decl.
(region_model::mark_as_valid_fd): New decl.
(region_model_context::get_fd_map): New pure virtual fn.
(noop_region_model_context::get_fd_map): New.
(region_model_context_decorator::get_fd_map): New.
* sm-fd.cc: Include "analyzer/program-state.h".
(fd_state_machine::describe_state_change): Handle transitions from
start state to valid states.
(fd_state_machine::mark_as_valid_fd): New.
(fd_state_machine::on_stmt): Add missing return for "creat".
(region_model::mark_as_valid_fd): New.
gcc/ChangeLog:
PR analyzer/106300
* doc/invoke.texi (Static Analyzer Options): Add "pipe" and
"pipe2" to the list of functions the analyzer has hardcoded
knowledge of.
gcc/testsuite/ChangeLog:
PR analyzer/106300
* gcc.dg/analyzer/pipe-1.c: New test.
* gcc.dg/analyzer/pipe-glibc.c: New test.
* gcc.dg/analyzer/pipe-manpages.c: New test.
* gcc.dg/analyzer/pipe2-1.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Jason Merrill [Thu, 20 Oct 2022 17:51:37 +0000 (13:51 -0400)]
tree: add build_string_literal overloads
Simplify several calls to build_string_literal by not requiring redundant
strlen or IDENTIFIER_* in the caller.
I also corrected a wrong comment on IDENTIFIER_LENGTH.
gcc/ChangeLog:
* tree.h (build_string_literal): New one-argument overloads that
take tree (identifier) and const char *.
* builtins.cc (fold_builtin_FILE)
(fold_builtin_FUNCTION)
* gimplify.cc (gimple_add_init_for_auto_var)
* vtable-verify.cc (verify_bb_vtables): Simplify calls.
gcc/cp/ChangeLog:
* cp-gimplify.cc (fold_builtin_source_location)
* vtable-class-hierarchy.cc (register_all_pairs): Simplify calls to
build_string_literal.
(build_string_from_id): Remove.
Thomas Schwinge [Mon, 24 Oct 2022 19:11:47 +0000 (21:11 +0200)]
libgomp/nvptx: Prepare for reverse-offload callback handling, resolve spurious SIGSEGVs
Per commit r13-3460-g131d18e928a3ea1ab2d3bf61aa92d68a8a254609
"libgomp/nvptx: Prepare for reverse-offload callback handling",
I'm seeing a lot of libgomp execution test regressions. Random
example, 'libgomp.c-c++-common/error-1.c':
[...]
GOMP_OFFLOAD_run: kernel main$_omp_fn$0: launch [(teams: 1), 1, 1] [(lanes: 32), (threads: 8), 1]
Thread 1 "a.out" received signal SIGSEGV, Segmentation fault.
0x00007ffff793b87d in GOMP_OFFLOAD_run (ord=<optimized out>, tgt_fn=<optimized out>, tgt_vars=<optimized out>, args=<optimized out>) at [...]/source-gcc/libgomp/plugin/plugin-nvptx.c:2127
2127 if (__atomic_load_n (&ptx_dev->rev_data->fn, __ATOMIC_ACQUIRE) != 0)
(gdb) print ptx_dev
$1 = (struct ptx_device *) 0x6a55a0
(gdb) print ptx_dev->rev_data
$2 = (struct rev_offload *) 0xffffffff00000000
(gdb) print ptx_dev->rev_data->fn
Cannot access memory at address 0xffffffff00000000
libgomp/
* plugin/plugin-nvptx.c (nvptx_open_device): Initialize
'ptx_dev->rev_data'.
Martin Liska [Mon, 24 Oct 2022 13:34:39 +0000 (15:34 +0200)]
x86: fix VENDOR_MAX enum value
PR target/107364
gcc/ChangeLog:
* common/config/i386/i386-cpuinfo.h (enum processor_vendor):
Reorder enum values as BUILTIN_VENDOR_MAX should not point
in the middle of the valid enum values.
Marek Polacek [Thu, 20 Oct 2022 19:55:28 +0000 (15:55 -0400)]
c++: ICE with invalid structured bindings [PR107276]
This test ICEs in C++23 because we reach the new code in do_auto_deduction:
30468 if (cxx_dialect >= cxx23
30469 && context == adc_return_type
30470 && (!AUTO_IS_DECLTYPE (auto_node)
30471 || !unparenthesized_id_or_class_member_access_p (init))
30472 && (r = treat_lvalue_as_rvalue_p (maybe_undo_parenthesized_ref (init),
30473 /*return*/true)))
where 'init' is "VIEW_CONVERT_EXPR<<<< error >>>>(y)", and then the move
in treat_lvalue_as_rvalue_p returns error_mark_node whereupon
set_implicit_rvalue_p crashes.
I don't think such V_C_Es are useful so let's not create them. But that
won't fix the ICE so I'm checking the return value of move. A structured
bindings decl can have an error type, that is set in cp_finish_decomp:
8908 TREE_TYPE (first) = error_mark_node;
therefore I think treat_lvalue_as_rvalue_p just needs to cope.
PR c++/107276
gcc/cp/ChangeLog:
* typeck.cc (treat_lvalue_as_rvalue_p): Check the return value of move.
gcc/ChangeLog:
* tree.cc (maybe_wrap_with_location): Don't create a location wrapper
when the type is erroneous.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/decomp4.C: New test.
Jakub Jelinek [Mon, 24 Oct 2022 15:53:16 +0000 (17:53 +0200)]
c, c++: Fix up excess precision handling of scalar_to_vector conversion [PR107358]
As mentioned earlier in the C++ excess precision support mail, the following
testcase is broken with excess precision both in C and C++ (though just in C++
it was triggered in real-world code).
scalar_to_vector is called in both FEs after the excess precision promotions
(or stripping of EXCESS_PRECISION_EXPR), so we can then get invalid
diagnostics that say float vector + float involves truncation (on ia32
from long double to float).
The following patch fixes that by calling scalar_to_vector on the operands
before the excess precision promotions, let scalar_to_vector just do the
diagnostics (it does e.g. fold_for_warn so it will fold
EXCESS_PRECISION_EXPR around REAL_CST to constants etc.) but will then
do the actual conversions using the excess precision promoted operands
(so say if we have vector double + (float + float) we don't actually do
vector double + (float) ((long double) float + (long double) float)
but
vector double + (double) ((long double) float + (long double) float)
2022-10-24 Jakub Jelinek <jakub@redhat.com>
PR c++/107358
gcc/c/
* c-typeck.cc (build_binary_op): Pass operands before excess precision
promotions to scalar_to_vector call.
gcc/cp/
* typeck.cc (cp_build_binary_op): Pass operands before excess precision
promotions to scalar_to_vector call.
gcc/testsuite/
* c-c++-common/pr107358.c: New test.
* g++.dg/cpp1y/pr68180.C: Remove -fexcess-precision=fast from
dg-options.
Tobias Burnus [Mon, 24 Oct 2022 14:58:43 +0000 (16:58 +0200)]
libgomp/nvptx: Prepare for reverse-offload callback handling
This patch adds a stub 'gomp_target_rev' in the host's target.c, which will
later handle the reverse offload.
For nvptx, it adds support for forwarding the offload gomp_target_ext call
to the host by setting values in a struct on the device and querying it on
the host - invoking gomp_target_rev on the result.
include/ChangeLog:
* cuda/cuda.h (enum CUdevice_attribute): Add
CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING.
(CU_MEMHOSTALLOC_DEVICEMAP): Define.
(cuMemHostAlloc): Add prototype.
libgomp/ChangeLog:
* config/nvptx/icv-device.c (GOMP_DEVICE_NUM_VAR): Remove
'static' for this variable.
* config/nvptx/libgomp-nvptx.h: New file.
* config/nvptx/target.c: Include it.
(GOMP_ADDITIONAL_ICVS): Declare extern var.
(GOMP_REV_OFFLOAD_VAR): Declare var.
(GOMP_target_ext): Handle reverse offload.
* libgomp-plugin.h (GOMP_PLUGIN_target_rev): New prototype.
* libgomp-plugin.c (GOMP_PLUGIN_target_rev): New, call ...
* target.c (gomp_target_rev): ... this new stub function.
* libgomp.h (gomp_target_rev): Declare.
* libgomp.map (GOMP_PLUGIN_1.4): New; add GOMP_PLUGIN_target_rev.
* plugin/cuda-lib.def (cuMemHostAlloc): Add.
* plugin/plugin-nvptx.c: Include libgomp-nvptx.h.
(struct ptx_device): Add rev_data member.
(nvptx_open_device): Remove async_engines query, last used in
r10-304-g1f4c5b9b; add unified-address assert check.
(GOMP_OFFLOAD_get_num_devices): Claim unified address
support.
(GOMP_OFFLOAD_load_image): Free rev_fn_table if no
offload functions exist. Make offload var available
on host and device.
(rev_off_dev_to_host_cpy, rev_off_host_to_dev_cpy): New.
(GOMP_OFFLOAD_run): Handle reverse offload.
Wilco Dijkstra [Mon, 24 Oct 2022 14:14:14 +0000 (15:14 +0100)]
[AArch64] Improve immediate expansion [PR106583]
Improve immediate expansion of immediates which can be created from a
bitmask immediate and 2 MOVKs. Simplify, refactor and improve efficiency
of bitmask checks. Move various immediate handling functions together
to avoid forward declarations.
This reduces the number of 4-instruction immediates in SPECINT/FP by 10-15%.
gcc/
PR target/106583
* config/aarch64/aarch64.cc (aarch64_internal_mov_immediate)
Add support for a bitmask immediate with 2 MOVKs.
(aarch64_check_bitmask): New function after refactorization.
(aarch64_bitmask_imm): Simplify replication of small modes.
Split function into 64-bit only version for efficiency.
(aarch64_move_imm): Move near other immediate functions.
(aarch64_uimm12_shift): Likewise.
(aarch64_clamp_to_uimm12_shift): Likewise.
(aarch64_movk_shift): Likewise.
(aarch64_replicate_bitmask_imm): Likewise.
(aarch64_and_split_imm1): Likewise.
(aarch64_and_split_imm2): Likewise.
(aarch64_and_bitmask_imm): Likewise.
(aarch64_movw_imm): Likewise.
gcc/testsuite/
PR target/106583
* gcc.target/aarch64/pr106583.c: Add new test.
Jakub Jelinek [Mon, 24 Oct 2022 14:25:29 +0000 (16:25 +0200)]
c++: Fix up constexpr handling of char/signed char/short pre/post inc/decrement [PR105774]
signed char, char or short int pre/post inc/decrement are represented by
normal {PRE,POST}_{INC,DEC}REMENT_EXPRs in the FE and only gimplification
ensures that the {PLUS,MINUS}_EXPR is done in unsigned version of those
types:
case PREINCREMENT_EXPR:
case PREDECREMENT_EXPR:
case POSTINCREMENT_EXPR:
case POSTDECREMENT_EXPR:
{
tree type = TREE_TYPE (TREE_OPERAND (*expr_p, 0));
if (INTEGRAL_TYPE_P (type) && c_promoting_integer_type_p (type))
{
if (!TYPE_OVERFLOW_WRAPS (type))
type = unsigned_type_for (type);
return gimplify_self_mod_expr (expr_p, pre_p, post_p, 1, type);
}
break;
}
This means during constant evaluation we need to do it similarly (either
using unsigned_type_for or using widening to integer_type_node).
The following patch does the latter.
2022-10-24 Jakub Jelinek <jakub@redhat.com>
PR c++/105774
* constexpr.cc (cxx_eval_increment_expression): For signed types
that promote to int, evaluate PLUS_EXPR or MINUS_EXPR in int type.
* g++.dg/cpp1y/constexpr-105774.C: New test.
Arsen Arsenović [Fri, 14 Oct 2022 10:04:51 +0000 (12:04 +0200)]
c-family: Implicitly return zero from main even on freestanding
... unless marked noreturn.
This should not get in anyone's way, but should permit the use of main()
in freestanding more easily, especially for writing test cases that
should work both in freestanding and hosted modes.
gcc/c/ChangeLog:
* c-decl.cc (finish_function): Ignore hosted when deciding
whether to implicitly return zero, but check noreturn.
* c-objc-common.cc (c_missing_noreturn_ok_p): Loosen the
requirements to just MAIN_NAME_P when hosted, or `int main'
otherwise.
gcc/cp/ChangeLog:
* cp-tree.h (DECL_MAIN_P): Move most logic, besides the hosted
check, from here...
(DECL_MAIN_ANY_P): ... to here, so that it can be reused ...
(DECL_MAIN_FREESTANDING_P): ... here, with an additional
constraint on (hosted OR return type == int)
* decl.cc (finish_function): Use DECL_MAIN_FREESTANDING_P
instead of DECL_MAIN_P, to loosen the hosted requirement, but
check noreturn, before adding implicit returns.
gcc/testsuite/ChangeLog:
* gcc.dg/noreturn-4.c: Removed.
* g++.dg/freestanding-main.C: New test.
* g++.dg/freestanding-nonint-main.C: New test.
* gcc.dg/freestanding-main.c: New test.
* gcc.dg/freestanding-nonint-main.c: New test.
Aldy Hernandez [Mon, 24 Oct 2022 10:37:25 +0000 (12:37 +0200)]
[PR tree-optimization/107355] Handle NANs in abs range-op entry.
The problem here is that the threader is coming up with a path where
the only valid result is a NAN. When the abs op1_range entry is
trying to add the negative posibility, it attempts to get the bounds
of the working range. NANs don't have bounds so they need to be
special cased.
PR tree-optimization/107355
gcc/ChangeLog:
* range-op-float.cc (foperator_abs::op1_range): Handle NAN.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/pr107355.c: New test.
Tobias Burnus [Mon, 24 Oct 2022 13:19:00 +0000 (15:19 +0200)]
OpenMP: Fix reverse offload GOMP_TARGET_REV IFN corner cases [PR107236]
For 'target parallel' and similarly nested directives, cgraph_node's
calls_declare_variant_alt was not set in the parent region node but in
cfun->decl. Hence, pass_omp_device_lower did not process handle the
internal function GOMP_TARGET_REV. - Solution is to set it to the
DECL_CONTEXT, which is set in adjust_context_and_scope.
The cgraph_node::create_clone issue is exposed with -O2 for the existing
libgomp.fortran/reverse-offload-1.f90.
PR middle-end/107236
gcc/ChangeLog:
* omp-expand.cc (expand_omp_target): Set calls_declare_variant_alt
in DECL_CONTEXT and not to cfun->decl.
* cgraphclones.cc (cgraph_node::create_clone): Copy also the
node's calls_declare_variant_alt value.
gcc/testsuite/ChangeLog:
* gfortran.dg/gomp/target-device-ancestor-6.f90: New test.
Kito Cheng [Fri, 30 Sep 2022 02:05:23 +0000 (10:05 +0800)]
RISC-V: Support --target-help for -mcpu/-mtune
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc (riscv_tunes): New.
(riscv_get_valid_option_values): New.
(TARGET_GET_VALID_OPTION_VALUES): New.
* config/riscv/riscv-cores.def (RISCV_TUNE): New, define options
for tune here.
(RISCV_CORE): Fix comment.
* config/riscv/riscv.cc (riscv_tune_info_table): Move definition to
riscv-cores.def.
Aldy Hernandez [Sun, 23 Oct 2022 14:51:17 +0000 (16:51 +0200)]
Check HONOR_NANS instead of flag_finite_math_only in frange:verify_range.
[Jakub and other FP experts, would this be OK, or am I missing
something?]
Vax does not seem to have !flag_finite_math_only, but float_type_node
does not HONOR_NANS. The check in frange::verify_range dependend on
flag_finite_math_only, which is technically not correct since
frange::set_varying() checks HONOR_NANS instead of
flag_finite_math_only.
I'm actually getting tired of flag_finite_math_only and
!flag_finite_math_only discrepancies in the selftests (Vax and rx-elf
come to mind). I think we should just test both alternatives in the
selftests as in this patch.
We could also check flag_finite_math_only=0 with a float_type_node
that does not HONOR_NANs, but I have no idea how to twiddle
FLOAT_MODE_FORMAT temporarily, and that may be over thinking it.
PR tree-optimization/107365
gcc/ChangeLog:
* value-range.cc (frange::verify_range): Predicate NAN check in
VARYING range on HONOR_NANS instead of flag_finite_math_only.
(range_tests_floats): Same.
(range_tests_floats_various): New.
(range_tests): Call range_tests_floats_various.
Torbjörn SVENSSON [Fri, 21 Oct 2022 10:29:13 +0000 (12:29 +0200)]
lto: Always quote path to touch
When generating the makefile, make sure that the paths are quoted so
that a native Windows path works within Cygwin.
Without this patch, this error is reported by the DejaGNU test suite:
make: [T:\ccMf0kI3.mk:3: T:\ccGEvdDp.ltrans0.ltrans.o] Error 1 (ignored)
The generated makefile fragment without the patch:
T:\ccGEvdDp.ltrans0.ltrans.o:
@T:\build\bin\arm-none-eabi-g++.exe '-xlto' ... '-o' 'T:\ccGEvdDp.ltrans0.ltrans.o' 'T:\ccGEvdDp.ltrans0.o'
@-touch -r T:\ccGEvdDp.ltrans0.o T:\ccGEvdDp.ltrans0.o.tem > /dev/null 2>&1 && mv T:\ccGEvdDp.ltrans0.o.tem T:\ccGEvdDp.ltrans0.o
.PHONY: all
all: \
T:\ccGEvdDp.ltrans0.ltrans.o
With the patch, the touch line would be replace with:
@-touch -r "T:\ccGEvdDp.ltrans0.o" "T:\ccGEvdDp.ltrans0.o.tem" > /dev/null 2>&1 && mv "T:\ccGEvdDp.ltrans0.o.tem" "T:\ccGEvdDp.ltrans0.o"
gcc/ChangeLog:
* lto-wrapper.cc: Quote paths in makefile.
Co-Authored-By: Yvan ROUX <yvan.roux@foss.st.com>
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Ju-Zhe Zhong [Mon, 24 Oct 2022 02:03:12 +0000 (10:03 +0800)]
RISC-V: Support (set (mem) (const_poly_int))
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_legitimize_move): Support (set (mem) (const_poly_int)).
Ju-Zhe Zhong [Mon, 24 Oct 2022 02:20:28 +0000 (10:20 +0800)]
RISC-V: Replace CONSTEXPR with constexpr
Move away from the pre-C++11 compatibility macro CONSTEXPR.
This patch is inspired by aarch64:
https://gcc.gnu.org/pipermail/gcc-patches/2022-October/603974.html.
gcc/ChangeLog:
* config/riscv/riscv-vector-builtins-bases.cc: Replace CONSTEXPR
with constexpr throughout.
* config/riscv/riscv-vector-builtins-shapes.cc (SHAPE): Likewise.
* config/riscv/riscv-vector-builtins.cc
(struct registered_function_hasher): Likewise.
* config/riscv/riscv-vector-builtins.h (struct rvv_arg_type_info):
Likewise.