David Malcolm [Fri, 18 Aug 2017 23:50:34 +0000 (23:50 +0000)]
jit: make simpler reproducers
The C reproducers generated by gcc_jit_context_dump_reproducer_to_file
contain numerous pointer values (from %p) to ensure uniqueness of the
identifiers, but this makes them less readable than they could be.
This patch updates reproducer::make_identifier so that the pointer
is only added if it's necessary for uniqueness.
gcc/jit/ChangeLog:
* jit-recording.c (class gcc::jit::reproducer): Rename field
"m_identifiers" to "m_map_memento_to_identifier". Add field
"m_set_identifiers" and struct hash_traits for it.
(gcc::jit::reproducer::reproducer): Update for above.
(convert_to_identifier): New function.
(gcc::jit::reproducer::ensure_identifier_is_unique): New method.
(gcc::jit::reproducer::make_identifier): Avoid appending the %p
unless necessary for uniqueness. Update for field renaming.
(gcc::jit::reproducer::get_identifier): Update for field renaming.
Peter Bergner [Fri, 18 Aug 2017 23:41:41 +0000 (18:41 -0500)]
re PR target/80210 (ICE in in extract_insn, at recog.c:2311 on ppc64 for with __builtin_pow)
gcc/
PR target/80210
* config/rs6000/rs6000.c (rs6000_activate_target_options): New function.
(rs6000_set_current_function): Rewrite function to use it.
gcc/testsuite/
PR target/80210
* gcc.target/powerpc/pr80210.c: New test.
Jonathan Wakely [Fri, 18 Aug 2017 18:20:43 +0000 (19:20 +0100)]
Simplify allocator usage in unordered containers
* include/bits/hashtable_policy.h (_ReuseOrAllocNode): Remove
__value_alloc_type and __value_alloc_traits typedefs.
(_ReuseOrAllocNode::operator()): Call construct and destroy on the
node allocator.
(_Hashtable_alloc): Simplify __value_alloc_traits typedef.
(_Hashtable_alloc<_NodeAlloc>::_M_allocate_node(_Args&&...)): Call
construct on the node allocator.
(_Hashtable_alloc<_NodeAlloc>::_M_deallocate_node(__node_type*)): Call
destroy on the node allocator.
David Malcolm [Fri, 18 Aug 2017 18:12:47 +0000 (18:12 +0000)]
C++: fix ordering of missing std #include suggestion (PR c++/81514)
gcc/cp/ChangeLog:
PR c++/81514
* name-lookup.c (maybe_suggest_missing_header): Convert return
type from void to bool; return true iff a suggestion was offered.
(suggest_alternative_in_explicit_scope): Move call to
maybe_suggest_missing_header to before use of best_match, and
return true if the former offers a suggestion.
gcc/testsuite/ChangeLog:
PR c++/81514
* g++.dg/lookup/empty.h: New file.
* g++.dg/lookup/missing-std-include-2.C: Replace include of
stdio.h with empty.h and a declaration of a "std::sprintf" not based
on a built-in.
H.J. Lu [Fri, 18 Aug 2017 09:38:38 +0000 (09:38 +0000)]
Add warn_if_not_aligned attribute
Add warn_if_not_aligned attribute as well as command line options:
-Wif-not-aligned and -Wpacked-not-aligned.
__attribute__((warn_if_not_aligned(N))) causes compiler to issue a
warning if the field in a struct or union is not aligned to N:
typedef unsigned long long __u64
__attribute__((aligned(4),warn_if_not_aligned(8)));
struct foo
{
int i1;
int i2;
__u64 x;
};
__u64 is aligned to 4 bytes. But inside struct foo, __u64 should be
aligned at 8 bytes. It is used to define struct foo in such a way that
struct foo has the same layout and x has the same alignment when __u64
is aligned at either 4 or 8 bytes.
Since struct foo is normally aligned to 4 bytes, a warning will be issued:
warning: alignment 4 of 'struct foo' is less than 8
Align struct foo to 8 bytes:
struct foo
{
int i1;
int i2;
__u64 x;
} __attribute__((aligned(8)));
silences the warning. It also warns the field with misaligned offset:
struct foo
{
int i1;
int i2;
int i3;
__u64 x;
} __attribute__((aligned(8)));
warning: 'x' offset 12 in 'struct foo' isn't aligned to 8
This warning is controlled by -Wif-not-aligned and is enabled by default.
When -Wpacked-not-aligned is used, the same warning is also issued for
the field with explicitly specified alignment in a packed struct or union:
Ian Lance Taylor [Fri, 18 Aug 2017 04:40:42 +0000 (04:40 +0000)]
cmd/go: pass -funwind-tables when compiling C code
Using -funwind-tables is necessary to permit Go code to correctly
throw a panic through C code. This hasn't been necessary in the past
as -funwind-tables is the default on x86. However, it is not the
default for PPC AIX.
Martin Liska [Thu, 17 Aug 2017 19:56:46 +0000 (21:56 +0200)]
Fix build of --enable-gather-detailed-mem-stats (PR bootstrap/81864).
2017-08-17 Martin Liska <mliska@suse.cz>
PR bootstrap/81864
* tree-loop-distribution.c (ddrs_table): Change type to pointer
type.
(get_data_dependence): Use it as pointer type.
(distribute_loop): Likewise.
Bill Schmidt [Thu, 17 Aug 2017 19:31:54 +0000 (19:31 +0000)]
altivec.md (UNSPEC_VMRGOW_DIRECT): New constant.
2017-08-17 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
* config/rs6000/altivec.md (UNSPEC_VMRGOW_DIRECT): New constant.
(p8_vmrgew_v4sf_direct): Generalize to p8_vmrgew_<mode>_direct.
(p8_vmrgow_<mode>_direct): New define_insn.
* config/rs6000/rs6000.c (altivec_expand_vec_perm_const): Properly
handle endianness for vmrgew and vmrgow permute patterns.
Peter Bergner [Thu, 17 Aug 2017 15:56:48 +0000 (10:56 -0500)]
re PR target/72804 (Poor code gen with -mvsx-timode)
gcc/
PR target/72804
* config/rs6000/vsx.md (*vsx_le_permute_<mode>): Add support for
operands residing in integer registers.
(*vsx_le_perm_load_<mode>): Likewise.
(*vsx_le_perm_store_<mode>): Likewise.
(define_peephole2): Add peepholes to optimize the above.
gcc/testsuite/
PR target/72804
* gcc.target/powerpc/pr72804.c: New test.
Marek Polacek [Thu, 17 Aug 2017 14:33:13 +0000 (14:33 +0000)]
re PR middle-end/81814 (Incorrect behaviour at -O0 (conditional operator))
PR middle-end/81814
* fold-const.c (operand_equal_for_comparison_p): Remove code that used
to mimic what shorten_compare did. Change the return type to bool.
(fold_cond_expr_with_comparison): Update call to
operand_equal_for_comparison_p.
(fold_ternary_loc): Likewise.
Alan Modra [Thu, 17 Aug 2017 02:03:03 +0000 (11:33 +0930)]
[RS6000] PR 80938, Don't emit frame info for regs that don't need saving
It is possible when using out-of-line register saves or store multiple
to save some registers unnecessarily, for example one reg in the block
saved might be unused. We don't need to emit frame info for those
registers as that just bloats the info, and also can result in an ICE
when shrink-wrap gives multiple paths through the function saving
different sets of registers. Join points need to have identical frame
register save state regardless of the path taken.
This patch reverts the previous fix for PR80939 "Use SAVE_MULTIPLE
only if we restore what it saves (PR80938)" and instead fixes the PR
by correcting the frame info. The change to rs6000_savres_strategy
is an optimization, but note that it hides the underlying problem in
the PR testcase.
PR target/80938
* config/rs6000/rs6000.c (rs6000_savres_strategy): Revert 2017-08-09.
Don't use store multiple if only one reg needs saving.
(interesting_frame_related_regno): New function.
(rs6000_frame_related): Don't emit frame info for regs that
don't need saving.
(rs6000_emit_epilogue): Likewise.
Nathan Sidwell [Wed, 16 Aug 2017 19:42:28 +0000 (19:42 +0000)]
tree-core.h (tree_type_non_common): Rename binfo to lang_1.
* tree-core.h (tree_type_non_common): Rename binfo to lang_1.
* tree.h (TYPE_BINFO): Use type_non_common.maxval.
(TYPE_LANG_SLOT_1): Use type_non_common.lang_1, for any type.
* tree.c (free_lang_data_in_type): Use else-if chain. Always
clear TYPE_LANG_1. Remove obsolete member-function stripping.
(find_decls_types_r): Comment about TYPE_MAX_VALUES_RAW.
(verify_type): Adjust for TYPE_BINFO move.
* lto-streamer-out.c (DFS::DFS_write_tree_body): No need to
process TYPE_BINFO directly.
(hash_tree): Likewise.
* tree-streamer-in.c (lto_input_ts_type_non_common_tree_pointers):
Likewise.
* tree-streamer-out.c (write_ts_type_non_common_tree_pointers):
Likewise.
lto/
* lto.c (mentions_vars_p_type): Use TYPE_LANG_SLOT_1.
(compare_tree_sccs_1): No need to compare TYPE_BINFO directly.
(lto_fixup_prevailing_decls): Use TYPE_LANG_SLOT_1.
Thomas Koenig [Wed, 16 Aug 2017 17:21:22 +0000 (17:21 +0000)]
re PR fortran/81116 (Last character of allocatable-length string reset to blank in an assigment)
2017-08-16 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/81116
* frontend-passes.c (realloc_string_callback): If expression is a
concatenation, also check for dependency.
(constant_string_length): Check for presence of symtree.
2017-08-16 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/81116
* gfortran.dg/realloc_on_assignment_29.f90: New test.
We weren't checking whether the phi in a conditional reduction was
used by the condition itself (which isn't a case we handle).
2017-08-11 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
PR tree-optimization/81835
* tree-vect-loop.c (vect_is_simple_reduction): Simply checks for
the phi SSA_NAME. Check that the condition in a COND_EXPR does
not depend on the phi.
gcc/testsuite/
PR tree-optimization/81835
* gcc.dg/vect/pr81815.c: New test.
Alan Modra [Wed, 16 Aug 2017 01:19:59 +0000 (10:49 +0930)]
[RS6000] Merge rs6000_reg_live_or_pic_offset_p into save_reg_p
rs6000_reg_live_or_pic_offset_p is just save_reg_p with special
handling for the pic register and eh_return. This merge also
simplifies the eh_return handling. The intent of
https://gcc.gnu.org/ml/gcc-patches/2010-09/msg01838.html was to say
the PIC reg needed to be saved for eh_return, not all gprs. Of
course, it doesn't hurt to say all gprs need to be saved for eh_return
as that is what the target-independent code does by setting DF live,
but it's unnecessary in the backend.
Joseph Myers [Tue, 15 Aug 2017 23:42:23 +0000 (00:42 +0100)]
Limit SH strncmp inline expansion (PR target/78460).
GCC mainline built for sh4-linux-gnu runs out of memory building a
glibc test, which calls strncmp with very large constant size
argument, resulting in the SH inline strncmp expansion trying to
inline a fully unrolled expansion of strncmp for that size.
This patch limits that fully unrolled expansion to the case of less
than 32 bytes. This is explicitly *not* trying to be optimal in any
way (very likely a lower threshold makes sense), just to limit enough
to avoid the out-of-memory issue in the glibc testsuite.
I have *not* run the GCC testsuite for SH. I have verified that this
allows the glibc testsuite to build OK, with both GCC mainline and GCC
7 branch (and that the included test builds quickly with patched GCC,
runs out of memory with unpatched GCC).
PR target/78460
PR target/67712
gcc:
* config/sh/sh-mem.cc (sh_expand_cmpnstr): Only unroll for
constant count if that count is less than 32.
gcc/testsuite:
* gcc.c-torture/compile/string-large-1.c: New test.
Bill Schmidt [Mon, 14 Aug 2017 14:26:33 +0000 (14:26 +0000)]
re PR target/79845 (rs6000: make code in rs6000.c more i18n-friendly)
[gcc]
2017-08-14 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
PR target/79845
* config/rs6000/linux64.h (INVALID_64BIT): Use quoted strings.
* config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin):
Likewise.
* config/rs6000/rs6000.c (rs6000_init_hard_regno_mode_ok): Use
quoted strings, and make more translator-friendly.
(darwin_rs6000_override_options): Likewise.
(rs6000_option_override_internal): Likewise.
(rs6000_return_in_memory): Fix overlong line.
(init_cmulative_args): Use quoted strings, and make more
translator-friendly.
(rs6000_pass_by_reference): Fix overlong line.
(def_builtin): Use quoted strings.
(altivec_expand_predicate_builtin): Use quoted strings, and make
more translator-friendly.
(htm_expand_builtin): Use quoted strings.
(cpu_expand_builtin): Use quoted strings, and make more
translator-friendly.
(altivec_expand_builtin): Likewise.
(paired_expand_predicate_builtin): Likewise.
(rs6000_invalid_builtin): Likewise.
(builtin_function_type): Use quoted strings.
(rs6000_expand_split_stack_prologue): Use quoted strings, and make
more translator-friendly.
(rs6000_trampoline_init): Likewise.
(rs6000_handle_altivec_attribute): Likewise.
(rs6000_inner_target_options): Use quoted strings.
(rs6000_disable_incompatible_switches): Likewise.
* config/rs6000/sysv4.h (SUBTARGET_OVERRIDE_OPTIONS): Use quoted
strings, and make more translator-friendly.
(SUBSUBTARGET_OVERRIDE_OPTIONS): Use quoted strings.
[gcc/testsuite]
2017-08-14 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
Uros Bizjak [Sun, 13 Aug 2017 16:08:25 +0000 (18:08 +0200)]
i386.md (*load_tp_<mode>): Redefine as define_insn_and_split.
* config/i386/i386.md (*load_tp_<mode>): Redefine as
define_insn_and_split. Split to a memory load from 0 in
DEFAULT_TLS_SEG_REG address space. Merge with *load_tp_x32
using PTR mode iterator.
(*load_tp_x32_zext"): Redefine as define_insn_and_split.
Split to a memory load from 0 in DEFAULT_TLS_SEG_REG address space.
(*add_tp_<mode>): Redefine as define_insn_and_split.
Split to an add with a memory load from 0 in DEFAULT_TLS_SEG_REG
address space. Merge with *add_tp_x32 using PTR mode iterator.
(*add_tp_x32_zext"): Redefine as define_insn_and_split.
Split to an add with a memory load from 0 in
DEFAULT_TLS_SEG_REG address space.
[PR79542][Ada] Fix ICE in dwarf2out.c with nested func. inlining
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79542 reports an ICE in
dwarf2out.c for an Ada testcase built with optimization.
This crash happens during the late generation pass because
add_gnat_descriptive_type cannot find the type DIE corresponding to some
descriptive type after having tried to generate it. This is because the
DIE was generated during the early generation pass, but then pruned by
the type pruning machinery. So why was it pruned?
We are in a situation where we have cloned types (because of inlining,
IIUC) whose TYPE_NAME have non-null DECL_ABSTRACT_ORIGIN attributes. As
a consequence:
* In modified_type_die, the "handle C typedef types" part calls
gen_type_die on the cloned type.
* gen_type_die matches a typedef variant, and then calls gen_decl_die
on its TYPE_NAME, which will end up calling gen_typedef_die.
* gen_typedef_die checks decl_ultimate_origin for this TYPE_DECL, and
finds one, so it only adds a DW_AT_abstract_origin attribute to the
DW_TAG_typedef DIE, but the cloned type itself does not get its own
DIE.
* Back in modified_type_die, the call to lookup_type_die on the type
passed to gen_type_die returns NULL.
In the end, whole type trees, i.e. the ones referenced by
DECL_ABSTRACT_ORIGIN attributes, are never referenced from type pruning
"roots" and are thus pruned. The descriptive type at stake here is one
of them, hence the assertion failure.
This patch attemps to fix that with what seems to be the most sensible
thing to do in my opinion: updating the "handle C typedef types" part in
modified_type_die to check decl_ultimate_origin before calling
gen_type_die: if that function returns something not null, then we know
that gen_type_die/gen_typedef_die will not generate a DIE for the input
type, so we try to process the ultimate origin instead. It also updates
in a similar way gen_type_die_with_usage, assert that when
gen_typedef_die is called on nodes that have an ultimate origin, this
origin is themselves.
gcc/
PR ada/79542
* dwarf2out.c (modified_type_die): For C typedef types that have
an ultimate origin, process the ultimate origin instead of the
input type.
(gen_typedef_die): Assert that input DECLs have no ultimate
origin.
(gen_type_die_with_usage): For typedef variants that have an
ultimate origin, just call gen_decl_die on the original DECL.
(process_scope_var): Avoid creating DIEs for local typedefs and
concrete static variables.
gcc/testsuite/
PR ada/79542
* gnat.dg/debug13.ads, gnat.dg/debug13.adb: New testcase.
Alan Modra [Sat, 12 Aug 2017 00:28:04 +0000 (09:58 +0930)]
[RS6000] linux startfile/endfile
These need to match the gnu-user.h definitions to support
--enable-default-pie. Otherwise we end up linking the wrong startup
files when defaulting to PIE.
PR target/81170
PR target/81295
* config/rs6000/sysv4.h (STARTFILE_LINUX_SPEC): Upgrade to
match gnu-user.h startfile.
(ENDFILE_LINUX_SPEC): Similarly.
Thomas Koenig [Fri, 11 Aug 2017 17:45:36 +0000 (17:45 +0000)]
re PR fortran/60355 ([F08] constraint C519 for BIND attribute not enforced)
2017-08-11 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/60355
* resolve.c (resolve_symbol): Adjust (and reformat)
comment. Perform check if a BIND(C) is declared
at module level regardless of whether it is typed
implicitly or not.
2017-08-11 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/60355
* gfortran.dg (bind_c_usage_30): New test.
The second loop in the testcase only vectorises if we can reverse
a vector and if aligned loads aren't required.
2017-08-10 Richard Sandiford <richard.sandiford@linaro.org>
gcc/testsuite/
PR testsuite/81738
* gcc.dg/vect/vect-alias-check-6.c: Move second function to...
* gcc.dg/vect/vect-alias-check-7.c: ...this new file. Require
vect_perm and vect_element_align for vectorization.
Jason Merrill [Thu, 10 Aug 2017 19:07:30 +0000 (15:07 -0400)]
PR c++/80452 - Core 1579, implicit move semantics on return/throw
* cp-tree.h (LOOKUP_PREFER_RVALUE): Now means that we've already
tentatively changed the lvalue to an rvalue.
* call.c (reference_binding): Remove LOOKUP_PREFER_RVALUE handling.
(build_over_call): If LOOKUP_PREFER_RVALUE, check that the first
parameter is an rvalue reference.
* except.c (build_throw): Do maybe-rvalue overload resolution twice.
* typeck.c (check_return_expr): Likewise.
H.J. Lu [Thu, 10 Aug 2017 15:29:05 +0000 (15:29 +0000)]
i386: Don't use frame pointer without stack access
When there is no stack access, there is no need to use frame pointer
even if -fno-omit-frame-pointer is used and caller's frame pointer is
unchanged.
gcc/
PR target/81736
* config/i386/i386.c (ix86_finalize_stack_realign_flags): Renamed
to ...
(ix86_finalize_stack_frame_flags): This. Also clear
frame_pointer_needed if -fno-omit-frame-pointer is used without
stack access.
(ix86_expand_prologue): Replace ix86_finalize_stack_realign_flags
with ix86_finalize_stack_frame_flags.
(ix86_expand_epilogue): Likewise.
(ix86_expand_split_stack_prologue): Likewise.
* doc/invoke.texi: Add a note for -fno-omit-frame-pointer.