Alan Modra [Fri, 30 Nov 2018 13:33:18 +0000 (00:03 +1030)]
[RS6000] num_insns_constant ICE
This patch came about from investigating an ICE that appeared when I
was retesting an old half-baked patch of mine to rs6000_rtx_costs.
If a const_double is fed to rs6000_is_valid_and_mask and from there to
rs6000_is_valid_mask where INTVAL is used, gcc will ICE.
The num_insns_constant ICE was introduced with git commit f337168d97.
However, the code was buggy before that. There was no point in
testing for a mask since the mask predicates only handle const_int.
In fact, I don't think the function ever handled floating point
constants that might match a load of minus one and mask. It does now.
I've added a few comments regarding splitters so the next person
looking at this code can see how this works.
The patch also extracts code out of num_insns_constant that needed to
handle multiple gprs for DFmode constants in 32-bit mode, to a
function that handles multiple gprs a little more generally. I don't
think there is any need for anything but the 32-bit DFmode case
currently, but this allows for possible future uses. The
CONST_WIDE_INT case is also not used currently, and needed fixing.
Adding CONST_WIDE_INT_NUNITS - 1 only makes sense if the elements of
the array were being shifted into a register of size larger than the
element size (which is 64-bits).
* config/rs6000/rs6000.c (num_insns_constant_gpr): Renamed from
num_insns_constant_wide. Make static. Revise comment.
(num_insns_constant_multi): New function.
(num_insns_constant): Formatting. Correct CONST_WIDE_INT
calculation. Simplify and extract code common to both
CONST_INT and CONST_DOUBLE. Add gcc_unreachable for unhandled
const_double modes.
* config/rs6000/rs6000-protos.h (num_insns_const_wide): Delete.
Andi Kleen [Thu, 29 Nov 2018 23:11:59 +0000 (23:11 +0000)]
Allow changing the fentry section per file and per function
When dynamically patching in/out instrumentation it can be useful
to handle different classes of functions differently. Add support
for changing the fentry section name on the command line
or as a function attributes. This allows to mark functions differently,
and handle them differently in dynamic patching.
Andi Kleen [Thu, 29 Nov 2018 23:11:53 +0000 (23:11 +0000)]
Support changing fentry name per function
It can be useful to have some classes of functions that use a different
__fentry__ instrumentation than others. Currently it is only
possible to disable instrumentation on the command line or with
no_instrument_function, but not to change the instrumentation function
on a case by case base.
Add some flexibility to allow to change the instrumentation function
name per file with an option or per function with a new attribute.
This also allows switching to nops for individual functions.
Andi Kleen [Thu, 29 Nov 2018 23:11:47 +0000 (23:11 +0000)]
Support instrumenting returns of instrumented functions
When instrumenting programs using __fentry__ it is often useful
to instrument the function return too. Traditionally this
has been done by patching the return address on the stack
frame on entry. However this is fairly complicated (trace
function has to emulate a stack) and also slow because
it causes a branch misprediction on every return.
Add an option to generate call or nop instrumentation for
every return instead, including patch sections.
This will increase the program size slightly, but can be a
lot faster and simpler.
This version only instruments true returns, not sibling
calls or tail recursion. This matches the semantics of the
original stack.
Eric Botcazou [Thu, 29 Nov 2018 23:08:09 +0000 (23:08 +0000)]
re PR target/87807 (passing float/double vectors as variadic args fails on-64bit SPARC)
PR target/87807
* config/sparc/sparc-modes.def: Minor tweak.
* config/sparc/sparc.c: Minor reordering.
(sparc_pass_by_reference): Move around.
(traverse_record_type): Change offset from HOST_WIDE_INT to int.
(classify_registers): Likewise for bitpos.
(function_arg_slotno): Remove dead test and tweak comments.
<MODE_RANDOM>: Remove useless assertion and test whether the
parameter is named in order to pass it in FP registers. Return
the regno for floating-point vector types.
(compute_int_layout): Change bitpos from HOST_WIDE_INT to int.
(compute_fp_layout): Likewise.
(count_registers): Likewise.
(assign_int_registers): Likewise.
(assign_fp_registers): Likewise.
(assign_registers): Likewise.
(function_arg_record_value): Change size from HOST_WIDE_INT to int
and use CEIL_NWORDS to compute the number of registers.
(function_arg_union_value): Minor tweaks.
(function_arg_vector_value): Add slotno and named parameters, use
CEIL_NWORDS to compute the number of registers.
(sparc_function_arg_1): Rework handling of vector types. Change
size from HOST_WIDE_INT to int.
(sparc_arg_partial_bytes): Rework handling of 32-bit ABI and deal
with vector types for the 64-bt ABI.
(sparc_function_arg_advance): Likewise.
(sparc_return_in_memory): Add reference to -fpcc-struct-return.
(sparc_struct_value_rtx): Return NULL_RTX instead of 0.
(sparc_function_value_1): Rework handling of vector types. Change
size from HOST_WIDE_INT to int.
Paolo Carlini [Thu, 29 Nov 2018 21:34:38 +0000 (21:34 +0000)]
decl.c (compute_array_index_type_loc): New, like the current compute_array_index_type but takes a location_t too.
/cp
2018-11-29 Paolo Carlini <paolo.carlini@oracle.com>
* decl.c (compute_array_index_type_loc): New, like the current
compute_array_index_type but takes a location_t too.
(compute_array_index_type): Forward to the latter.
(create_array_type_for_decl): Use compute_array_index_type_loc.
/testsuite
2018-11-29 Paolo Carlini <paolo.carlini@oracle.com>
David Malcolm [Thu, 29 Nov 2018 21:21:56 +0000 (21:21 +0000)]
C++: namespaces and scopes for enum values (PR c++/88121)
Consider this test case:
namespace json
{
enum { JSON_OBJECT };
}
void test ()
{
JSON_OBJECT;
}
which erroneously accesses an enum value in another namespace without
qualifying the access.
GCC 6 through 8 issue a suggestion that doesn't mention the namespace:
<source>: In function 'void test()':
<source>:8:3: error: 'JSON_OBJECT' was not declared in this scope
JSON_OBJECT;
^~~~~~~~~~~
<source>:8:3: note: suggested alternative:
<source>:3:10: note: 'JSON_OBJECT'
enum { JSON_OBJECT };
^~~~~~~~~~~
which is suboptimal.
I made the problem worse with r265610, which consolidates the single
suggestion into the error, and emits:
<source>: In function 'void test()':
<source>:8:3: error: 'JSON_OBJECT' was not declared in this scope; did
you mean 'JSON_OBJECT'?
8 | JSON_OBJECT;
| ^~~~~~~~~~~
| JSON_OBJECT
<source>:3:10: note: 'JSON_OBJECT' declared here
3 | enum { JSON_OBJECT };
| ^~~~~~~~~~~
where the message:
'JSON_OBJECT' was not declared in this scope; did you mean 'JSON_OBJECT'?
is nonsensical.
This patch tweaks dump_scope to detect unscoped enums, and to use the
enclosing namespace for them, so that the CONST_DECL is dumped as
"json::JSON_OBJECT".
This changes the output for the above so that it refers to the
namespace, fixing the issue:
<source>:8:3: error: 'JSON_OBJECT' was not declared in this scope; did
you mean 'json::JSON_OBJECT'?
9 | JSON_OBJECT;
| ^~~~~~~~~~~
| json::JSON_OBJECT
<source>3:10: note: 'json::JSON_OBJECT' declared here
3 | enum { JSON_OBJECT };
| ^~~~~~~~~~~
The patch also fixes scope-printing for values within scoped enums.
To exercise this, the patch extends the scanner for namespaces for
exact matches for a name, so that we also scan inside scoped
enums, to cover the case where someone doesn't supply the scope.
Hence with the patch given e.g.:
enum class vegetable { CARROT, TURNIP };
we're able to offer e.g.:
suggestions-scoped-enums.C:50:3: error: 'CARROT' was not declared in
this scope; did you mean 'vegetable::CARROT'?
50 | CARROT;
| ^~~~~~
| vegetable::CARROT
and this exercises the code path above. The patch updates dump_scope
for scoped enums so that we print the scope when printing the
value ("vegetable::CARROT"), rather than just the name of the value
("CARROT").
Finally, the patch adds spell-corrections within a scoped enum,
giving e.g.:
suggestions-scoped-enums.C:18:14: error: 'TURNUP' is not a member of
'vegetable'; did you mean 'TURNIP'?
18 | vegetable::TURNUP;
| ^~~~~~
| TURNIP
gcc/cp/ChangeLog:
PR c++/88121
* cp-name-hint.h (suggest_alternative_in_scoped_enum): New decl.
* error.c (dump_scope): Ensure that we print any scope for values
of unscoped enums. Print the scope of values of scoped enums.
(qualified_name_lookup_error): Offer suggestions for failures
within scoped enums by calling suggest_alternative_in_scoped_enum.
* name-lookup.c (class namespace_hints): Update comment to mention
scoped enums.
(namespace_hints::namespace_hints): Call
maybe_add_candidate_for_scoped_enum.
(namespace_hints::maybe_add_candidate_for_scoped_enum): New member
(suggest_alternatives_for): Update comment to mention scoped
enums.
(suggest_alternative_in_scoped_enum): New function.
gcc/testsuite/ChangeLog:
PR c++/88121
* g++.dg/lookup/suggestions-scoped-enums.C: New test.
* g++.dg/lookup/suggestions-unscoped-enums.C: New test.
Martin Sebor [Thu, 29 Nov 2018 18:03:18 +0000 (18:03 +0000)]
PR c/88091 - c-c++-common/Wconversion-real.c etc. FAIL
gcc/c/ChangeLog:
PR c/88091
* c-typeck.c (convert_argument): Add a parameter. Adjust indentation.
(convert_arguments): Add comments. Pass additional argument to
the function above.
Martin Sebor [Thu, 29 Nov 2018 17:48:58 +0000 (17:48 +0000)]
PR c/88172 - attribute aligned of zero silently accepted but ignored
PR c/88172 - attribute aligned of zero silently accepted but ignored
PR testsuite/88208 - new test case c-c++-common/builtin-has-attribute-3.c in r266335 has multiple excess errors
PR c/88172
PR testsuite/88208
* c-attribs.c (common_handle_aligned_attribute): Silently avoid setting
alignments to values less than the target requires.
(has_attribute): For attribute aligned consider both the attribute
and the alignment bits.
* c-common.c (c_init_attributes): Optionally issue a warning for
zero alignment.
Qing Zhao [Thu, 29 Nov 2018 16:06:03 +0000 (16:06 +0000)]
Add a new option -flive-patching={inline-only-static|inline-clone}
to support live patching in GCC.
2018-11-29 qing zhao <qing.zhao@oracle.com>
gcc/ChangeLog:
* cif-code.def (EXTERN_LIVE_ONLY_STATIC): New CIF code.
* common.opt: Add -flive-patching flag.
* doc/invoke.texi: Document -flive-patching.
* flag-types.h (enum live_patching_level): New enum.
* ipa-inline.c (can_inline_edge_p): Disable external functions from
inlining when flag_live_patching is LIVE_PATCHING_INLINE_ONLY_STATIC.
* opts.c (control_options_for_live_patching): New function.
(finish_options): Make flag_live_patching incompatible with flag_lto.
Control IPA optimizations based on different levels of
flag_live_patching.
gcc/testsuite/ChangeLog:
* gcc.dg/live-patching-1.c: New test.
* gcc.dg/live-patching-2.c: New test.
* gcc.dg/live-patching-3.c: New test.
* gcc.dg/tree-ssa/writeonly-3.c: New test.
* gcc.target/i386/ipa-stack-alignment-2.c: New test.
2018-11-29 Edward Smith-Rowland <3dw4rd@verizon.net>
Only include bits/stl_algo.h for C++20.
* include/std/deque: Only include bits/stl_algo.h for C++20.
* include/std/string: Ditto.
* include/std/vector: Ditto.
Jakub Jelinek [Thu, 29 Nov 2018 14:33:27 +0000 (15:33 +0100)]
re PR target/54700 (Optimize away x<0 as mask argument of a blend.)
PR target/54700
* config/i386/sse.md (ssebytemode): Add V16SI, V8SI and V4SI entries.
(ssefltmodesuffix, ssefltvecmode): New define_mode_attrs.
(*<sse4_1>_blendv<ssemodesuffix><avxsizesuffix>_lt,
*<sse4_1>_blendv<ssefltmodesuffix><avxsizesuffix>_ltint,
*<sse4_1_avx2>_pblendvb_lt): New define_insns.
* g++.target/i386/sse4_1-pr54700-1.C: New test.
* g++.target/i386/sse4_1-pr54700-2.C: New test.
* g++.target/i386/avx-pr54700-1.C: New test.
* g++.target/i386/avx-pr54700-2.C: New test.
* g++.target/i386/avx2-pr54700-1.C: New test.
* g++.target/i386/avx2-pr54700-2.C: New test.
* g++.target/i386/sse4_1-check.h: New file.
* g++.target/i386/avx-check.h: New file.
* g++.target/i386/avx2-check.h: New file.
* g++.target/i386/m128-check.h: New file.
* g++.target/i386/m256-check.h: New file.
* g++.target/i386/avx-os-support.h: New file.
Jakub Jelinek [Thu, 29 Nov 2018 14:32:00 +0000 (15:32 +0100)]
re PR target/88152 (optimize SSE & AVX char compares with subsequent movmskb)
PR target/88152
* tree.h (build_uniform_cst, uniform_integer_cst_p): Declare.
* tree.c (build_uniform_cst, uniform_integer_cst_p): New functions.
* match.pd (define_predicates): Add uniform_integer_cst_p.
(cmp @0 INTEGER_CST@1, cmp (convert?@2 @0) INTEGER_CST@1): Adjust
so that it works also for vector comparisons with uniform constants
with INTEGER_CST element.
* g++.dg/tree-ssa/pr88152-1.C: New test.
* g++.dg/tree-ssa/pr88152-2.C: New test.
Jakub Jelinek [Thu, 29 Nov 2018 14:23:21 +0000 (15:23 +0100)]
re PR target/88234 (UBsan and runtime error: signed integer overflow using unsigned vector)
PR target/88234
* config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): For
vec_add and vec_sub builtins, perform PLUS_EXPR or MINUS_EXPR
in unsigned_type_for instead of vector integral type where overflow
doesn't wrap.
There can be at most one .resolver clone per function
2018-11-29 Michael Ploujnikov <michael.ploujnikov@oracle.com>
There can be at most one .resolver clone per function
* config/rs6000/rs6000.c (make_resolver_func): Generate
resolver symbol with clone_function_name instead of
clone_function_name_numbered.
Jonathan Wakely [Thu, 29 Nov 2018 12:32:57 +0000 (12:32 +0000)]
PR libstdc++/88119 use alignof in std::alignment_of, not __alignof__
Now that __alignof__ and alignof sometimes disagree it matters which one
we use. The standard says that std::alignment_of<T>::value equals
alignof(T), so we need to use that.
Change the only uses of alignment_of to use __alignof__ to avoid a
change in alignment.
PR libstdc++/88119
* include/ext/aligned_buffer.h (__aligned_membuf): Add comment.
(__aligned_buffer): Use __alignof__ instead of std::alignment_of.
* include/std/type_traits (alignment_of): Use alignof instead of
__alignof__.
* testsuite/20_util/alignment_of/value.cc: Fix test to check values
match alignof not __alignof__, as required by the standard.
Andre Vieira [Thu, 29 Nov 2018 10:20:13 +0000 (10:20 +0000)]
[PATCH] [Arm] Fix fpu configurations for Cortex-R7 and Cortex-R8
gcc/ChangeLog:
2018-11-29 Andre Vieira <andre.simoesdiasvieira@arm.com>
PR target/88224
* config/arm/arm-cpus.in (armv7-r): Add FP16conv configurations.
(cortex-r7, cortex-r8): Update default and add new configuration.
* doc/invoke.texi (armv7-r): Add two new vfp options.
(nofp.dp): Add cortex-r7 and cortex-r8 to the list of targets that
support this option.
Alan Modra [Thu, 29 Nov 2018 05:03:01 +0000 (15:33 +1030)]
[RS6000] PR11848 rs6000_emit_move long double split
This split is disabled for power7 and up, so we don't often see its
bad effects. However, on a powerpc-linux compiler (which defaults
to PPC750 judging from rs6000/sysv4.h) we see
long double ld1 (void) { return 1.0L; }
compiled with -msoft-float -O2 -S resulting in
ld1:
li 3,0
li 4,0
mr 6,4
mr 5,3
li 4,0
lis 3,0x3ff0
blr
Things go awry in init-regs, with the TFmode reg being initialized to
zero on seeing the subreg from the split. (And that initialization
itself is split by rs6000_emit_move!) Later passes apparently don't
clean up the rubbish.
Since the split was added for Darwin (as the comment says), let's get
rid of it on other targets.
* config/rs6000/rs6000.c (rs6000_emit_move): Disable long
double split for targets other than Darwin.
Alan Modra [Thu, 29 Nov 2018 04:59:19 +0000 (15:29 +1030)]
[RS6000] CONST_DOUBLE tidy
Once upon a time CONST_DOUBLE was used to hold large integer constants
that didn't fit into a CONST_INT. Now that CONST_INT is always at
least 64 bits, and the rs6000 backend uses CONST_WIDE_INT for larger
integers, there is no need for old code dealing with integers in
CONST_DOUBLE. The rs6000 backend also doesn't create DImode subregs
of TFmode CONST_DOUBLE, as once we did. This patch cleans up a few
leftovers from the past.
* config/rs6000/predicates.md (easy_fp_constant): Remove code
dealing with integers in const_double. Assert on unexpected
modes. Delete superfluous ABI_V4 test.
* config/rs6000/rs6000.c (rs6000_emit_move): Comment fixes.
Don't call easy_fp_constant for Pmode.
(rs6000_hash_constant): Remove code dealing with integers in
const_double.
(rs6000_legitimate_constant_p): Likewise.
(output_toc): Formatting, use CONST_DOUBLE_P.
Alan Modra [Thu, 29 Nov 2018 04:58:08 +0000 (15:28 +1030)]
[RS6000] "G" and "H" constraints
The patch fixes two cases where the "G" and "H" constraints were used
incorrectly. Their purpose is calculating insn lengths. Thus it
never makes sense to put "GH" together or with "F" in an insn
alternative.
movdi_internal32 used "GHF" in an alternative so I replaced that with
"F", and added length attributes for the insn, which were missing.
There are some formatting changes too, to make alternatives line up
with attributes.
The FMOVE128 version of mov<mode>_softfloat also had "GHF" in an
alternative, so "GH" is dropped and "F" moved to a separate
alternative in order to get insn lengths correct. Well by correct I
mean we need to choose the maximum insn length otherwise branches
might not reach. Note the very large length for "F". I think it
would be better to force soft-float long double constants to memory in
64-bit mode, but that's a patch for another day.
* config/rs6000/constraints.md (G, H): Comment on purpose of
constraint. Correct mode comments and "G" mode test.
* config/rs6000/rs6000.md (movdi_internal32): Remove "GH" from
alternative handling "F". Add length attr. Formatting.
(mov<mode>_softfloat <FMOVE128>): Delete "GH" from
alternative, and move "F" to separate alternative. Correct
insn lengths.
Alan Modra [Thu, 29 Nov 2018 04:56:33 +0000 (15:26 +1030)]
[RS6000] Bogus easy_fp_constant call
easy_fp_constant accepts const_double, easy_vector_constant accepts
const_vector. Calling one from the other therefore will always return
false. I believe the zero_constant call in easy_vector_constant will
cover the 0.0 case of easy_fp_constant.
Alan Modra [Thu, 29 Nov 2018 04:53:49 +0000 (15:23 +1030)]
[RS6000] inline plt call sequences
Finally, the point of the previous patches in this series, support for
inline PLT calls, keyed off -fno-plt. This emits code using new
relocations that tie all insns in the sequence together, so that the
linker can edit the sequence back to a direct call should the call
target turn out to be local. An example of ELFv2 code to call puts is
as follows:
"addis 12,2,puts@plt@ha" and "ld 12,puts@plt@l(12)" are also supported
by the assembler. gcc instead uses the explicit R_PPC64_PLT16_HA and
R_PPC64_PLT16_LO_DS relocs because when the call is to __tls_get_addr
an extra reloc is emitted at every place where one is shown above, to
specify the __tls_get_addr arg. The linker expects the extra reloc to
come first. .reloc enforces that ordering.
The patch also changes code emitted for longcalls if the assembler
supports the new marker relocs, so that these too can be edited. One
side effect of longcalls using PLT16 relocs is that they can now be
resolved lazily by ld.so.
I don't support lazy inline PLT calls for ELFv1, because ELFv1 would
need barriers to reliably load both the function address and toc
pointer from the PLT. ELFv1 -fno-plt uses the longcall sequence
instead, which isn't edited by GNU ld.
* config.in (HAVE_AS_PLTSEQ): Add.
* config/rs6000/predicates.md (indirect_call_operand): New.
* config/rs6000/rs6000-protos.h (rs6000_pltseq_template),
(rs6000_sibcall_sysv): Declare.
* config/rs6000/rs6000.c (init_cumulative_args): Set cookie
CALL_LONG for -fno-plt.
(print_operand <T, z, 0>): Handle UNSPEC_PLTSEQ.
(rs6000_indirect_call_template_1): Emit .reloc directives for
UNSPEC_PLTSEQ calls.
(rs6000_pltseq_template): New function.
(rs6000_longcall_ref): Add arg parameter. Use PLT16 insns if
relocs supported by assembler. Move SYMBOL_REF test to callers.
(rs6000_call_aix): Adjust rs6000_longcall_ref call. Package
insns in UNSPEC_PLTSEQ, preserving original func_desc.
(rs6000_call_sysv): Likewise.
(rs6000_sibcall_sysv): New function.
* config/rs6000/rs6000.h (HAVE_AS_PLTSEQ): Provide default.
* config/rs6000/rs6000.md (UNSPEC_PLTSEQ, UNSPEC_PLT16_HA,
UNSPEC_PLT16_LO): New.
(pltseq_tocsave, pltseq_plt16_ha, pltseq_plt16_lo, pltseq_mtctr): New.
(call_indirect_nonlocal_sysv): Don't differentiate zero from non-zero
cookie in constraints. Test explicitly for flags in length attr.
Handle unspec operand 1.
(call_value_indirect_nonlocal_sysv): Likewise.
(call_indirect_aix, call_value_indirect_aix): Handle unspec operand 1.
(call_indirect_elfv2, call_value_indirect_elfv2): Likewise.
(sibcall, sibcall_value): Use rs6000_sibcall_sysv.
(sibcall_indirect_nonlocal_sysv): New pattern.
(sibcall_value_indirect_nonlocal_sysv): Likewise.
(sibcall_nonlocal_sysv, sibcall_value_nonlocal_sysv): Remove indirect
call alternatives.
* configure.ac: Check for gas plt sequence marker support.
* configure: Regenerate.
Alan Modra [Thu, 29 Nov 2018 04:47:51 +0000 (15:17 +1030)]
[RS6000] Use standard call patterns for __tls_get_addr calls
The current code handling __tls_get_addr calls for powerpc*-linux
generates a call then overwrites the call insn with a special
tls_{gd,ld}_{aix,sysv} pattern. It's done that way to support
!TARGET_TLS_MARKERS, where the arg setup insns need to be emitted
immediately before the branch and link. When TARGET_TLS_MARKERS, the
arg setup insns are split from the actual call, but we then have a
non-standard call pattern that needs to be carried through to output.
This patch changes that scheme, to instead use the standard call
patterns for __tls_get_addr calls, except for the now rare
!TARGET_TLS_MARKERS case. Doing it this way should be better for
maintenance as the !TARGET_TLS_MARKERS code can eventually disappear.
It also makes it possible to support longcalls (and in following
patches, inline plt calls) for __tls_get_addr without introducing yet
more special call patterns.
__tls_get_addr calls do however need to be different to standard
calls, because when TARGET_TLS_MARKERS the calls are decorated with an
argument specifier, eg. "bl __tls_get_addr(thread_var@tlsgd)" that
causes a reloc to be emitted by the assembler tying the call to its
arg setup insns. I chose to smuggle the arg in the currently unused
stack size rtl.
I've also introduced rs6000_call_sysv to generate rtl for sysv calls,
as rs6000_call_aix does for aix and elfv2 calls. This allows
rs6000_longcall_ref to be local to rs6000.c since the calls in the
expanders never did anything for darwin.
* config/rs6000/predicates.md (unspec_tls): New.
* config/rs6000/rs6000-protos.h (rs6000_call_template),
(rs6000_sibcall_template): Update prototype.
(rs6000_longcall_ref): Delete.
(rs6000_call_sysv): Declare.
* config/rs6000/rs6000.c (edit_tls_call_insn): New function.
(global_tlsarg): New variable.
(rs6000_legitimize_tls_address): Rewrite __tls_get_addr call
handling.
(print_operand): Extract UNSPEC_TLSGD address operand.
(rs6000_call_template, rs6000_sibcall_template): Remove arg
parameter, extract from second call operand instead.
(rs6000_longcall_ref): Make static, localize vars.
(rs6000_call_aix): Rename parameter to reflect new usage. Take
tlsarg from global_tlsarg. Don't create unused rtl or nop insns.
(rs6000_sibcall_aix): Rename parameter to reflect new usage. Take
tlsarg from global_tlsarg.
(rs6000_call_sysv): New function.
* config/rs6000/rs6000.md: Adjust rs6000_call_template and
rs6000_sibcall_template throughout.
(tls_gd_aix, tls_gd_sysv, tls_gd_call_aix, tls_gd_call_sysv): Delete.
(tls_ld_aix, tls_ld_sysv, tls_ld_call_aix, tls_ld_call_sysv): Delete.
(tls_gdld_nomark): New insn.
(tls_gd): Swap operand order. Simplify mode selection.
(tls_gd_high, tls_gd_low): Swap operand order.
(tls_ld): Remove const_int 0 vector element from UNSPEC_TLSLD.
Simplify mode selection.
(tls_ld_high, tls_ld_low): Similarly adjust UNSPEC_TLSLD.
(call, call_value): Don't assert for second call operand.
Use rs6000_call_sysv.
Alan Modra [Thu, 29 Nov 2018 04:45:00 +0000 (15:15 +1030)]
[RS6000] Replace TLSmode with P, and correct tls call mems
There is really no need to define a TLSmode mode iterator that is
identical (since !TARGET_64BIT == TARGET_32BIT) to the much used P
mode iterator. It's nonsense to think we might ever want to support
32-bit TLS on 64-bit or vice versa! The patch also fixes a minor
error in the call mems. All other direct calls use (call (mem:SI ..)).
* config/rs6000/rs6000.md (TLSmode): Delete mode iterator. Replace
with P throughout except for call mems which should use SI.
(tls_abi_suffix, tls_sysv_suffix, tls_insn_suffix): Delete mode
attributes. Replace with bits, mode and ptrload respectively.
Alan Modra [Thu, 29 Nov 2018 04:43:21 +0000 (15:13 +1030)]
[RS6000] rs6000_indirect_call_template
Like the last patch for external calls, now handle most assembly code
for indirect calls in one place. The patch also merges some insns,
correcting some !rs6000_speculate_indirect_jumps cases branching to
LR, which don't require a speculation barrier.
* config/rs6000/rs6000-protos.h (rs6000_indirect_call_template),
(rs6000_indirect_sibcall_template): Declare.
* config/rs6000/rs6000.c (rs6000_indirect_call_template_1),
(rs6000_indirect_call_template, rs6000_indirect_sibcall_template):
New functions.
* config/rs6000/rs6000.md (call_indirect_nonlocal_sysv),
(call_value_indirect_nonlocal_sysv, sibcall_nonlocal_sysv),
(call_indirect_aix, call_value_indirect_aix): Use
rs6000_indirect_call_template and rs6000_indirect_sibcall_template.
call_indirect_elfv2, call_value_indirect_elfv2): Likewise, and
handle both speculation and non-speculation cases.
(call_indirect_aix_nospec, call_value_indirect_aix_nospec): Delete.
(call_indirect_elfv2_nospec, call_value_indirect_elfv2_nospec): Delete.
Implement the proposed semantics from P1164R0, which reverts the changes
of LWG 2935. This means that failure to create a directory because a
non-directory already exists with that name will be reported as an
error.
While rewriting the function, also fix PR 87846, which is a result of
the C++17 changes to how a trailing slash on a path affects the last
component of a path.
PR libstdc++/86910
PR libstdc++/87846
* src/filesystem/ops.cc (experimental::create_directories): Report
an error when the path resolves to an existing non-directory (P1164).
* src/filesystem/std-ops.cc (create_directories): Likewise. Handle
empty filenames due to trailing slashes.
* testsuite/27_io/filesystem/operations/create_directories.cc: Test
when some component of the path exists and is not a directory. Test
trailing slashes.
* testsuite/experimental/filesystem/operations/create_directories.cc:
Likewise.
Iain Buclaw [Wed, 28 Nov 2018 21:53:06 +0000 (21:53 +0000)]
libphobos: Merge common version blocks using arch_any conditions
This sets a precedence in upstream for merging architecture agnostic
C bindings into one block, rather than separate duplicated blocks.
A nice side-effect is it almost completes the C bindings for
s390-linux-gnu and sparc-linux-gnu, and fixes a bug on MIPS32 where
O_SYNC had the wrong value.
Nathan Sidwell [Wed, 28 Nov 2018 21:25:06 +0000 (21:25 +0000)]
[PR c++/87531] operator= lookup in templates
https://gcc.gnu.org/ml/gcc-patches/2018-11/msg02301.html
PR c++/87531
* class.c (finish_struct): In a template, add artificial using
decl for operator=.
* predict.c (determine_unlikely_bbs): Forward declare; also determine
edges that are always known to be taken because it is only likely
edge out of given BB.
(tree_estimate_probability): Call before profile guessing to get bit
of extra precision.
* gcc.dg/predict-13.c: Update template.
* gcc.dg/predict-13b.c: New testcase.
* gcc.dg/predict-22.c: New testcase.
* gcc.dg/tree-ssa/ipa-split-4.c: Change abort to other function to
get sane profile.
Ian Lance Taylor [Wed, 28 Nov 2018 18:08:21 +0000 (18:08 +0000)]
compiler: inline functions with assignments and return statements
Support inlining functions that contain only assignments and return
statements, with expressions of either constants or parameters.
Functions that contain other kinds of statements or expressions are
not yet inlined. With this change, about 100 functions in the
standard library are inlinable.
Jeff Law [Wed, 28 Nov 2018 17:26:03 +0000 (10:26 -0700)]
constraints.md: Add "C" constraint for call insns.
* config/h8300/constraints.md: Add "C" constraint for call insns.
* config/h8300/h8300.md (call, call_value): Turn into a define_expand
and define_insn pair. Move invalid call targets into a register in
the expander and fix constraints in the matching pattern.
* config/h8300/predicates.md (call_expander_operand): Renamed from
call_insn_operand. Reject things we shouldn't be trying to handle.
(call_insn_operand): New predicate for use by the call/call_value
insns.
(small_call_insn_operand): Update appropriately.
Jonathan Wakely [Wed, 28 Nov 2018 17:07:22 +0000 (17:07 +0000)]
Fix undefined references in libstdc++fs.a
The recent patch for PR 83306 removed the fs_err_concat functions that
were used by the experimental::filesystem::filesystem_error class as
well. This fixes it by doing the string generation directly in
filesystem_error::_M_gen_what() instead of using the removed function.
Jonathan Wakely [Wed, 28 Nov 2018 15:36:56 +0000 (15:36 +0000)]
Apply resolution for LWG DR 3096
Add fix for "path::lexically_relative is confused by trailing slashes".
* doc/xml/manual/intro.xml: Document LWG 3096 change.
* src/filesystem/std-path.cc (path::lexically_relative(const path&)):
Treat a final empty element equivalently to a final dot element.
* testsuite/27_io/filesystem/path/generation/relative.cc: Add checks
for the examples in the DR.
Jonathan Wakely [Wed, 28 Nov 2018 15:27:11 +0000 (15:27 +0000)]
PR libstdc++/83306 make filesystem_error no-throw copyable
The class API provides no way to modify the members, so we can share
them between copies of the same object. Copying becomes a simple
reference count update, which doesn't throw.
Also adjust the what() string to allow distinguishing between an empty
path passed to the constructor, and no path.
PR libstdc++/83306
* include/bits/fs_path.h (filesystem_error): Move data members into
pimpl class owned by shared_ptr. Remove inline definitions of member
functions.
* src/filesystem/std-path.cc (filesystem_error::_Impl): Define.
(filesystem_error): Define member functions.
* testsuite/27_io/filesystem/filesystem_error/cons.cc: New test.
* testsuite/27_io/filesystem/filesystem_error/copy.cc: New test.
Tom de Vries [Wed, 28 Nov 2018 14:06:23 +0000 (14:06 +0000)]
[libbacktrace] Fix segfault upon allocation failure
If the allocation of abbrevs->abbrevs in read_abbrevs fails, then
abbrevs->num_abbrevs remains nonzero, and consequently free_abbrevs will
segfault when accessing abbrevs->abbrevs.
Fix this by setting abbrevs->num_abbrevs only after abbrevs->abbrevs
allocation has succeeded.
Bootstrapped and reg-tested on x86_64.
2018-11-28 Tom de Vries <tdevries@suse.de>
* dwarf.c (read_abbrevs): Fix handling of abbrevs->abbrevs allocation
failure.
Richard Biener [Wed, 28 Nov 2018 13:51:42 +0000 (13:51 +0000)]
re PR tree-optimization/88223 (Wrong code for intrinsic memmove)
2018-11-28 Richard Biener <rguenther@suse.de>
PR tree-optimization/88223
* tree-ssa-sccvn.c (vn_reference_lookup_3): When skipping
over a stored-same value may-alias store make sure to consider
partial overlaps which are valid when TBAA reasonings do not
apply and byte-granular overlaps are possible at all.
Richard Biener [Wed, 28 Nov 2018 13:04:27 +0000 (13:04 +0000)]
re PR tree-optimization/88217 (Compile time and memory hog w/ -O2 -fstrict-enums -fno-tree-forwprop -fno-tree-fre)
2018-11-28 Richard Biener <rguenther@suse.de>
PR tree-optimization/88217
* vr-values.c (vr_values::extract_range_from_phi_node): Make
sure to handle results > +INF and < -INF correctly when
trying to drop down to +INF - 1 or -INF + 1.
Richard Biener [Wed, 28 Nov 2018 11:01:06 +0000 (11:01 +0000)]
re PR tree-optimization/79351 (Invalid tree PRE optimization around compound literal)
2018-11-28 Richard Biener <rguenther@suse.de>
PR tree-optimization/79351
* tree-ssa-sccvn.c (vn_reference_lookup_3): For assignments from
empty CONSTRUCTORs ensure the store is at a constant position.
Jakub Jelinek [Wed, 28 Nov 2018 08:54:31 +0000 (09:54 +0100)]
re PR target/88189 (ix86_expand_sse_movcc and blend for scalars)
PR target/88189
* config/i386/i386.c (ix86_expand_sse_movcc): Handle DFmode and
SFmode using sse4_1_blendvs[sd] with TARGET_SSE4_1. Formatting fixes.
* config/i386/sse.md (sse4_1_blendv<ssemodesuffix>): New pattern.
* gcc.target/i386/sse4_1-pr88189-1.c: New test.
* gcc.target/i386/sse4_1-pr88189-2.c: New test.
* gcc.target/i386/avx-pr88189-1.c: New test.
* gcc.target/i386/avx-pr88189-2.c: New test.
Jakub Jelinek [Wed, 28 Nov 2018 08:50:53 +0000 (09:50 +0100)]
re PR c++/87476 (char-array initialized from wide-string)
PR c++/87476
* typeck2.c (digest_init_r): Re-add handing of signed/unsigned char
strings and add it to the initialization of wide array from non-wide
string diagnostics too.
* g++.dg/cpp0x/pr87476-1.C: New test.
* g++.dg/cpp0x/pr87476-2.C: New test.
Jakub Jelinek [Wed, 28 Nov 2018 08:49:08 +0000 (09:49 +0100)]
re PR sanitizer/88215 (UBSAN: Internal compiler error with attribute(unused))
PR c++/88215
* c-ubsan.c: Include langhooks.h.
(ubsan_instrument_division): Change gcc_assert that main variants
of op0 and op1 types are equal to gcc_checking_assert that the
main variants are compatible types.
Jonathan Wakely [Tue, 27 Nov 2018 23:35:17 +0000 (23:35 +0000)]
Clean up temporary files created by std::filesystem testsuite
* testsuite/27_io/filesystem/operations/canonical.cc: Remove
directory created by test.
* testsuite/27_io/filesystem/operations/symlink_status.cc: Remove
symlink created by test.
Ian Lance Taylor [Tue, 27 Nov 2018 23:29:15 +0000 (23:29 +0000)]
compiler: record final type for numeric expressions
Inlinable function bodies are generated after the determine_types pass,
so we know the type for all constants. Rather than try to determine
it again when inlining, record the type in the export data, using a
$convert expression. Reduce the number of explicit $convert
expressions by recording a type context with the expected type in
cases where that type is known.
Jonathan Wakely [Tue, 27 Nov 2018 23:25:56 +0000 (23:25 +0000)]
PR libstdc++/67843 set shared_ptr lock policy at build-time
This resolves a longstanding issue where the lock policy for shared_ptr
reference counting depends on compilation options when the header is
included, so that different -march options can cause ABI changes. For
example, objects compiled with -march=armv7 will use atomics to
synchronize reference counts, and objects compiled with -march=armv5t
will use a mutex. That means the shared_ptr control block will have a
different layout in different objects, causing ODR violations and
undefined behaviour. This was the root cause of PR libstdc++/42734 as
well as PR libstdc++/67843.
The solution is to decide on the lock policy at build time, when
libstdc++ is configured. The configure script checks for the
availability of the necessary atomic built-ins for the target and fixes
that choice permanently. Different -march flags used to compile user
code will not cause changes to the lock policy. This results in an ABI
change for certain compilations, but only where there was already an ABI
incompatibility between the libstdc++.so library and objects built with
an incompatible -march option. In general, this means a more stable ABI
that isn't silently altered when -march flags make addition atomic ops
available.
To force a target to use "atomic" or "mutex" the new configure option
--with-libstdcxx-lock-policy can be used.
In order to turn ODR violations into linker errors, the uses of
shared_ptr in filesystem directory iterators have been replaced
with __shared_ptr, and explicit instantiations are declared. This
ensures that object files using those types cannot link to libstdc++
libs unless they use the same lock policy.
PR libstdc++/67843
* acinclude.m4 (GLIBCXX_ENABLE_LOCK_POLICY): Add new macro
that defines _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY.
* config.h.in: Regenerate.
* configure: Regenerate.
* configure.ac: Use GLIBCXX_ENABLE_LOCK_POLICY.
* doc/xml/manual/configure.xml: Document new configure option.
* include/bits/fs_dir.h (directory_iterator): Use __shared_ptr
instead of shared_ptr.
(recursive_directory_iterator): Likewise.
(__shared_ptr<_Dir>): Add explicit instantiation declaration.
(__shared_ptr<recursive_directory_iterator::_Dir_stack>): Likewise.
* include/bits/shared_ptr_base.h (__allocate_shared, __make_shared):
Add default template argument for _Lock_policy template parameter.
* include/ext/concurrence.h (__default_lock_policy): Check macro
_GLIBCXX_HAVE_ATOMIC_LOCK_POLICY instead of checking if the current
target supports the builtins for compare-and-swap.
* src/filesystem/std-dir.cc (__shared_ptr<_Dir>): Add explicit
instantiation definition.
(__shared_ptr<recursive_directory_iterator::_Dir_stack>): Likewise.
(directory_iterator, recursive_directory_iterator): Use __make_shared
instead of make_shared.
Ian Lance Taylor [Tue, 27 Nov 2018 21:40:56 +0000 (21:40 +0000)]
compiler: add result parameter names for inlinable functions
An inlinable function body may need to refer to result parameters, so
each result parameter needs a name. We already give them all names in
start_function (via create_result_variables). Change the export data
so that for an inlinable function we use those names for the function
declaration's result parameters.
Ian Lance Taylor [Tue, 27 Nov 2018 21:34:44 +0000 (21:34 +0000)]
compiler: finalize types parsed for inline functions
When we inline functions, we may parse types that we have not seen
before inlining. Inlining runs after the finalize_methods pass, so
those types will not be finalized, meaning that we don't have an
accurate list of which methods they support. Explicitly finalize them
when we parse them.
Ian Lance Taylor [Tue, 27 Nov 2018 21:25:58 +0000 (21:25 +0000)]
compiler: add '$' to names in expression export data
For inlined function bodies we're going to need to refer to variables,
so change the existing export data to add a '$' to names that look
like identifiers: true, false, nil, convert.
While we're here drop an unnecessary space character after operators.
Ian Lance Taylor [Tue, 27 Nov 2018 20:07:15 +0000 (20:07 +0000)]
compiler: change expression importing to use Import_expression
Change expression importing to use a new abstract interface class
Import_expression, so that we can more easily import expressions from
inlinable function bodies. This is a refactoring with no affect on
compiler behavior.
Ian Lance Taylor [Tue, 27 Nov 2018 19:57:45 +0000 (19:57 +0000)]
compiler: pass a Location to import_expression
Separate the Location that import_expression uses when creating a new
Expression from the Location used to report an error. This is a step
toward importing expressions for inlined functions. This is a pure
refactoring that does not affect compiler behavior.
Ian Lance Taylor [Tue, 27 Nov 2018 18:55:56 +0000 (18:55 +0000)]
compiler: change Expression export to use Export_function_body
In preparation for writing expressions to inline function bodies,
change the existing expression export code to use Export_function_body
rather than Export. Adjust existing expression exporters accordingly.
This is a refactoring that doesn't affect compiler output.