RE: [PATCH][GCC][mid-end] Add a hook to support telling the mid-end when to probe the stack [patch (2/6)]

2018-10-09 Thread Richard Biener
On Tue, 9 Oct 2018, Tamar Christina wrote:

> Hi All,
> 
> I'm looking for permission to backport this patch to the GCC-8 branch
> to fix PR86486.
> 
> OK for backport?

This doesn't seem to fix a regression and it's been on trunk only
for a few days.

Richard.

> Thanks,
> Tamar
> 
> > -Original Message-
> > From: Jeff Law 
> > Sent: Wednesday, July 11, 2018 19:53
> > To: Tamar Christina ; gcc-patches@gcc.gnu.org
> > Cc: nd ; rguent...@suse.de; i...@airs.com
> > Subject: Re: [PATCH][GCC][mid-end] Add a hook to support telling the mid-
> > end when to probe the stack [patch (2/6)]
> > 
> > On 07/11/2018 05:21 AM, Tamar Christina wrote:
> > > Hi All,
> > >
> > > This patch adds a hook to tell the mid-end about the probing
> > > requirements of the target.  On AArch64 we allow a specific range for
> > > which no probing needs to be done.  This same range is also the amount
> > > that will have to be probed up when a probe is needed after dropping the
> > stack.
> > >
> > > Defining this probe comes with the extra requirement that the outgoing
> > > arguments size of any function that uses alloca and stack clash be at
> > > the very least 8 bytes.  With this invariant we can skip doing the
> > > zero checks for alloca and save some code.
> > >
> > > A simplified version of the AArch64 stack frame is:
> > >
> > >+---+
> > >|   |
> > >|   |
> > >|   |
> > >+---+
> > >|LR |
> > >+---+
> > >|FP |
> > >+---+
> > >|dynamic allocations| -\  probe range hook effects these
> > >+---+   --\   and ensures that outgoing stack
> > >|padding|  -- args is always > 8 when alloca.
> > >+---+  ---/   Which means it's always safe to probe
> > >|outgoing stack args|-/   at SP
> > >+---+
> > >
> > >
> > > This allows us to generate better code than without the hook without
> > > affecting other targets.
> > >
> > > With this patch I am also removing the
> > > stack_clash_protection_final_dynamic_probe
> > > hook which was added specifically for AArch64 but that is no longer 
> > > needed.
> > >
> > > Bootstrapped Regtested on aarch64-none-linux-gnu, x86_64-pc-linux-gnu
> > and no issues.
> > > Both targets were tested with stack clash on and off by default.
> > >
> > > Ok for trunk?
> > >
> > > Thanks,
> > > Tamar
> > >
> > > gcc/
> > > 2018-07-11  Tamar Christina  
> > >
> > >   PR target/86486
> > >   * explow.c (anti_adjust_stack_and_probe_stack_clash): Support
> > custom
> > >   probe ranges.
> > >   * target.def (stack_clash_protection_alloca_probe_range): New.
> > >   (stack_clash_protection_final_dynamic_probe): Remove.
> > >   * targhooks.h (default_stack_clash_protection_alloca_probe_range)
> > New.
> > >   (default_stack_clash_protection_final_dynamic_probe): Remove.
> > >   * targhooks.c: Likewise.
> > >   * doc/tm.texi.in
> > (TARGET_STACK_CLASH_PROTECTION_ALLOCA_PROBE_RANGE): New.
> > >   (TARGET_STACK_CLASH_PROTECTION_FINAL_DYNAMIC_PROBE):
> > Remove.
> > >   * doc/tm.texi: Regenerate.
> > >
> > The control flow is a bit convoluted here, but after a few false starts 
> > where I
> > thought this was wrong, I think it's OK.
> > 
> > Jeff
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> 
> 

-- 
Richard Biener 
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 
21284 (AG Nuernberg)


Re: [PATCH] ASAN: emit line information of stack variables.

2018-10-09 Thread Martin Liška
PING^1

On 9/27/18 10:55 AM, Martin Liška wrote:
> Hi.
> 
> I've noticed ASAN can inform user about location of stack variables
> when a stack violation is detected.
> 
> Sample example:
> 
> ...
>   This frame has 3 object(s):
> [32, 36) 'counter' (line 3) <== Memory access at offset 36 overflows this 
> variable
> [96, 100) 'size' (line 5)
> [160, 164) 'length' (line 6)
> ...
> 
> I consider that handy so that I implemented that as well.
> 
> Ready after it finishes tests?
> Martin
> 
> gcc/ChangeLog:
> 
> 2018-09-27  Martin Liska  
> 
>   * asan.c (asan_emit_stack_protection): If a stack variable
>   is located in a same file as current function, then emit
>   line info into variable definition string.
> 
> gcc/testsuite/ChangeLog:
> 
> 2018-09-27  Martin Liska  
> 
>   * c-c++-common/asan/pr64820.c: Add line number to scanned
>   pattern.
>   * c-c++-common/asan/use-after-return-1.c: Likewise.
>   * g++.dg/asan/function-argument-1.C (main): Likewise.
>   * g++.dg/asan/function-argument-2.C (main): Likewise.
>   * g++.dg/asan/function-argument-3.C (main): Likewise.
>   * g++.dg/asan/use-after-scope-1.C (main): Likewise.
>   * g++.dg/asan/use-after-scope-2.C (main): Likewise.
>   * g++.dg/asan/use-after-scope-types-1.C (main): Likewise.
>   * g++.dg/asan/use-after-scope-types-2.C (main): Likewise.
>   * g++.dg/asan/use-after-scope-types-3.C (main): Likewise.
>   * g++.dg/asan/use-after-scope-types-4.C (main): Likewise.
>   * g++.dg/asan/use-after-scope-types-5.C (main): Likewise.
>   * gcc.dg/asan/pr78541.c (main): Likewise.
>   * gcc.dg/asan/use-after-scope-1.c (main): Likewise.
>   * gcc.dg/asan/use-after-scope-10.c (main): Likewise.
>   * gcc.dg/asan/use-after-scope-2.c (main): Likewise.
>   * gcc.dg/asan/use-after-scope-3.c (main): Likewise.
>   * gcc.dg/asan/use-after-scope-5.c (main): Likewise.
>   * gcc.dg/asan/use-after-scope-9.c (main): Likewise.
> ---
>  gcc/asan.c| 22 +--
>  gcc/testsuite/c-c++-common/asan/pr64820.c |  2 +-
>  .../c-c++-common/asan/use-after-return-1.c|  2 +-
>  .../g++.dg/asan/function-argument-1.C |  2 +-
>  .../g++.dg/asan/function-argument-2.C |  2 +-
>  .../g++.dg/asan/function-argument-3.C |  2 +-
>  gcc/testsuite/g++.dg/asan/use-after-scope-1.C |  2 +-
>  gcc/testsuite/g++.dg/asan/use-after-scope-2.C |  2 +-
>  .../g++.dg/asan/use-after-scope-types-1.C |  2 +-
>  .../g++.dg/asan/use-after-scope-types-2.C |  2 +-
>  .../g++.dg/asan/use-after-scope-types-3.C |  2 +-
>  .../g++.dg/asan/use-after-scope-types-4.C |  2 +-
>  .../g++.dg/asan/use-after-scope-types-5.C |  2 +-
>  gcc/testsuite/gcc.dg/asan/pr78541.c   |  2 +-
>  gcc/testsuite/gcc.dg/asan/use-after-scope-1.c |  2 +-
>  .../gcc.dg/asan/use-after-scope-10.c  |  2 +-
>  gcc/testsuite/gcc.dg/asan/use-after-scope-2.c |  2 +-
>  gcc/testsuite/gcc.dg/asan/use-after-scope-3.c |  2 +-
>  gcc/testsuite/gcc.dg/asan/use-after-scope-5.c |  2 +-
>  gcc/testsuite/gcc.dg/asan/use-after-scope-9.c |  2 +-
>  20 files changed, 39 insertions(+), 21 deletions(-)
> 
> 



Re: [PATCH] ASAN: emit line information of stack variables.

2018-10-09 Thread Jakub Jelinek
On Thu, Sep 27, 2018 at 10:55:10AM +0200, Martin Liška wrote:
> @@ -1281,15 +1284,30 @@ asan_emit_stack_protection (rtx base, rtx pbase, 
> unsigned int alignb,
>pp_space (&asan_pp);
>pp_wide_integer (&asan_pp, offsets[l - 1] - offsets[l]);
>pp_space (&asan_pp);
> +
> +  expanded_location xloc
> + = expand_location (DECL_SOURCE_LOCATION (decl));
> +  char location[32];
> +
> +  if (xloc.file == cfun_xloc.file)
> + sprintf (location, ":%d", xloc.line);
> +  else
> + location[0] = '\0';
> +
>if (DECL_P (decl) && DECL_NAME (decl))
>   {
> -   pp_decimal_int (&asan_pp, IDENTIFIER_LENGTH (DECL_NAME (decl)));
> +   unsigned l

Shadowing a variable is not a good idea.  Can you use say idlen
or something similar (we have l and length taken already)?

> + = IDENTIFIER_LENGTH (DECL_NAME (decl)) + strlen (location);
> +   pp_decimal_int (&asan_pp, l);
> pp_space (&asan_pp);
> pp_tree_identifier (&asan_pp, DECL_NAME (decl));
> +   pp_string (&asan_pp, location);
>   }
>else
>   pp_string (&asan_pp, "9 ");
> -  pp_space (&asan_pp);
> +
> +  if (l > 2)
> + pp_space (&asan_pp);

Otherwise LGTM.

Jakub


[PATCH] Remove dead functions and fix VMS target by moving back some functions.

2018-10-09 Thread Martin Liška
Hi.

Utilizing rtags' --find-dead-functions I'm suggesting a removal of part
of the functions reported with the script. I built all cross compilers
defined in contrib/config-list.mk and I fixed VMS targets that I broke
in previous removal.

If the folks are happy with the removal, I can probably continue with that
at some point in stage3 or so.

Ready for trunk?
Thanks,
Martin
>From f69d866da42a46783ab57181692583d2ecf30c49 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Fri, 5 Oct 2018 16:59:07 +0200
Subject: [PATCH] Remove dead functions and fix VMS target by moving back some
 functions.

gcc/ChangeLog:

2018-10-09  Martin Liska  

	* attribs.c (register_attribute): Remove unused functions.
	* cfganal.c (control_dependences::clear_control_dependence_bitmap): Likewise.
	(bitmap_union_of_succs): Likewise.
	* cfganal.h (bitmap_union_of_succs): Likewise.
	* cfgloop.c (loop_exits_to_bb_p): Likewise.
	* cfgloop.h (loop_exits_to_bb_p): Likewise.
	* cgraph.h (compute_call_stmt_bb_frequency): Likewise.
	* cgraphbuild.c (compute_call_stmt_bb_frequency): Likewise.
	* cselib.c (cselib_dummy_expand_value_rtx_cb): Likewise.
	* cselib.h (cselib_dummy_expand_value_rtx_cb): Likewise.
	* df-core.c (df_reg_defined): Likewise.
	(df_reg_used): Likewise.
	* df-scan.c (df_hard_reg_used_count): Likewise.
	* df.h (df_reg_defined): Likewise.
	(df_reg_used): Likewise.
	(df_hard_reg_used_count): Likewise.
	* dojump.c (init_pending_stack_adjust): Likewise.
	* dojump.h (init_pending_stack_adjust): Likewise.
	* dwarf2out.c (add_AT_vms_delta): Move function back after
	removal.
	(dwarf2out_set_demangle_name_func): REmove unused functions.
	* dwarf2out.h (dwarf2out_set_demangle_name_func): Likewise.
	* emit-rtl.c (emit_jump_insn_before_noloc): Likewise.
	(emit_call_insn_before_noloc): Likewise.
	(emit_barrier_before): Likewise.
	(emit_call_insn_after_noloc): Likewise.
	(emit_call_insn_after_setloc): Likewise.
	(emit_jump_insn_before_setloc): Likewise.
	(emit_call_insn_before_setloc): Likewise.
	(emit_call_insn_before): Likewise.
	* except.c (remove_eh_handler): Likewise.
	(get_eh_region_from_rtx): Likewise.
	* except.h (remove_eh_handler): Likewise.
	(get_eh_region_from_rtx): Likewise.
	* fold-const.c (div_if_zero_remainder): Likewise.
	(fold_unary_to_constant): Likewise.
	* fold-const.h (fold_unary_to_constant): Likewise.
	(div_if_zero_remainder): Likewise.
	* function.c (get_hard_reg_initial_reg): Likewise.
	(get_last_funcdef_no): Likewise.
	* function.h (get_hard_reg_initial_reg): Likewise.
	(get_last_funcdef_no): Likewise.
	* ggc-common.c (ggc_cleared_alloc_htab_ignore_args): Likewise.
	(ggc_cleared_alloc_ptr_array_two_args): Likewise.
	(ggc_splay_alloc): Likewise.
	(ggc_splay_dont_free): Likewise.
	* gimple-expr.c (is_gimple_address): Likewise.
	* gimple-expr.h (is_gimple_address): Likewise.
	* gimple-iterator.c (gsi_for_phi): Likewise.
	* gimple-iterator.h (gsi_for_phi): Likewise.
	* gimple-ssa-sprintf.c (struct format_result): Likewise.
	(format_result::operator+=): Likewise.
	(struct directive): Likewise.
	* gimple-ssa-warn-alloca.c (struct alloca_type_and_limit): Likewise.
	* gimple.c (gimple_unsigned_type): Likewise.
	(gimple_call_builtin_p): Likewise.
	* gimple.h (gimple_unsigned_type): Likewise.
	(gimple_call_builtin_p): Likewise.
	* gimplify.c (gimple_current_bind_expr): Likewise.
	* gimplify.h (gimple_current_bind_expr): Likewise.
	* haifa-sched.c (haifa_classify_insn): Likewise.
	* hsa-common.c (hsa_add_kernel_dependency): Likewise.
	(hsa_brig_function_name): Likewise.
	* hsa-common.h (hsa_add_kernel_dependency): Likewise.
	(hsa_brig_function_name): Likewise.
	* ipa-cp.c (ipcp_vr_lattice::meet_with): Likewise.
	* ipa-devirt.c (vtable_pointer_value_to_binfo): Likewise.
	* ipa-icf-gimple.c (func_checker::compare_tree_ssa_label): Likewise.
	* ipa-icf-gimple.h: Likewise.
	* ipa-icf.c (sem_item::sem_item): Likewise.
	(sem_function::sem_function): Likewise.
	(sem_function::icf_handled_component_p): Likewise.
	(sem_variable::sem_variable): Likewise.
	* ipa-icf.h: Likewise.
	* ipa-param-manipulation.c (index_in_adjustments_multiple_times_p): Likewise.
	(ipa_combine_adjustments): Likewise.
	* ipa-param-manipulation.h (ipa_combine_adjustments): Likewise.
	* ipa-prop.h (ipa_create_all_node_params): Likewise.
	(ipa_create_all_edge_args): Likewise.
	* ipa-ref.h: Likewise.
	* ipa-utils.h (vtable_pointer_value_to_binfo): Likewise.
	* lto-section-in.c (lto_delete_in_decl_state): Likewise.
	* lto-streamer-in.c (lto_input_data_block): Likewise.
	* lto-streamer.c (gate_lto_out): Likewise.
	* lto-streamer.h (lto_delete_in_decl_state): Likewise.
	(gate_lto_out): Likewise.
	(lto_input_data_block): Likewise.
	* predict.c (edge_probability_reliable_p): Likewise.
	* predict.h (edge_probability_reliable_p): Likewise.
	* read-md.c (md_reader::read_name_or_nil): Likewise.
	* read-md.h (class md_reader): Likewise.
	* rtl.h (get_first_nonnote_insn): Likewise.
	(emit_jump_insn_before_noloc): Likewise.
	(emit_jump_insn_before_setloc): Likewise.
	(emit_call_

Re: [PATCH] Come up with --param asan-stack-small-redzone (PR sanitizer/81715).

2018-10-09 Thread Martin Liška
PING^1

On 9/26/18 11:33 AM, Martin Liška wrote:
> On 9/25/18 5:53 PM, Jakub Jelinek wrote:
>> On Tue, Sep 25, 2018 at 05:26:44PM +0200, Martin Liška wrote:
>>> The only missing piece is how to implement asan_emit_redzone_payload more 
>>> smart.
>>> It means doing memory stores with 8,4,2,1 sizes in order to reduce # of 
>>> insns.
>>> Do we have somewhere a similar code?
>>
>> Yeah, that is a very important optimization.  I wasn't using DImode because
>> at least on x86_64 64-bit constants are quite expensive and on several other
>> targets even more so, so SImode was a compromise to get size of the prologue
>> under control and not very slow.  What I think we want is figure out ranges
> 
> Ah, some time ago, I remember you mentioned the 64-bit constants are expensive
> (even on x86_64). Btw. it's what clang used for the red zone instrumentation.
> 
>> of shadow bytes we want to initialize and the values we want to store there,
>> perhaps take also into account strict alignment vs. non-strict alignment,
>> and perform kind of store merging for it.  Given that 2 shadow bytes would
>> be only used for the very small variables (<=4 bytes in size, so <= 0.5
>> bytes of shadow), we'd just need a way to remember the 2 shadow bytes across
>> handling adjacent vars and store it together.
> 
> Agree, it's implemented in next version of patch.
> 
>>
>> I think we want to introduce some define for minimum red zone size and use
>> it instead of the granularity (granularity is 8 bytes, but minimum red zone
>> size if we count into it also the very small variable size is 16 bytes).
>>
>>> --- a/gcc/asan.h
>>> +++ b/gcc/asan.h
>>> @@ -102,6 +102,26 @@ asan_red_zone_size (unsigned int size)
>>>return c ? 2 * ASAN_RED_ZONE_SIZE - c : ASAN_RED_ZONE_SIZE;
>>>  }
>>>  
>>> +/* Return how much a stack variable occupy on a stack
>>> +   including a space for redzone.  */
>>> +
>>> +static inline unsigned int
>>> +asan_var_and_redzone_size (unsigned int size)
>>
>> The argument needs to be UHWI, otherwise you do a wrong thing for
>> say 4GB + 4 bytes long variable.  Ditto the result.
>>
>>> +{
>>> +  if (size <= 4)
>>> +return 16;
>>> +  else if (size <= 16)
>>> +return 32;
>>> +  else if (size <= 128)
>>> +return 32 + size;
>>> +  else if (size <= 512)
>>> +return 64 + size;
>>> +  else if (size <= 4096)
>>> +return 128 + size;
>>> +  else
>>> +return 256 + size;
>>
>> I'd prefer size + const instead of const + size operand order.
>>
>>> @@ -1125,13 +1125,13 @@ expand_stack_vars (bool (*pred) (size_t), struct 
>>> stack_vars_data *data)
>>>   && stack_vars[i].size.is_constant ())
>>> {
>>>   prev_offset = align_base (prev_offset,
>>> -   MAX (alignb, ASAN_RED_ZONE_SIZE),
>>> +   MAX (alignb, ASAN_SHADOW_GRANULARITY),
>>
>> Use that ASAN_MIN_RED_ZONE_SIZE (16) here.
>>
>>> !FRAME_GROWS_DOWNWARD);
>>>   tree repr_decl = NULL_TREE;
>>> + poly_uint64 size =  asan_var_and_redzone_size 
>>> (stack_vars[i].size.to_constant ());
>>
>> Too long line.  Two spaces instead of one.  Why poly_uint64?
>> Plus, perhaps if data->asan_vec is empty (i.e. when assigning the topmost
>> automatic variable in a frame), we should ensure that size is at least
>> 2 * ASAN_RED_ZONE_SIZE (or just 1 * ASAN_RED_ZONE_SIZE). 
>>
>>>   offset
>>> -   = alloc_stack_frame_space (stack_vars[i].size
>>> -  + ASAN_RED_ZONE_SIZE,
>>> -  MAX (alignb, ASAN_RED_ZONE_SIZE));
>>> +   = alloc_stack_frame_space (size,
>>> +  MAX (alignb, 
>>> ASAN_SHADOW_GRANULARITY));
>>
>> Again, too long line and we want 16 instead of 8 here too.
>>>  
>>>   data->asan_vec.safe_push (prev_offset);
>>>   /* Allocating a constant amount of space from a constant
>>> @@ -2254,7 +2254,7 @@ expand_used_vars (void)
>>>  & ~(data.asan_alignb - HOST_WIDE_INT_1)) - sz;
>>>   /* Allocating a constant amount of space from a constant
>>>  starting offset must give a constant result.  */
>>> - offset = (alloc_stack_frame_space (redzonesz, ASAN_RED_ZONE_SIZE)
>>> + offset = (alloc_stack_frame_space (redzonesz, ASAN_SHADOW_GRANULARITY)
>>
>> and here too.
>>
>>  Jakub
>>
> 
> The rest is also implemented as requested. I'm testing Linux kernel now, will 
> send
> stats to the PR created for it.
> 
> Patch survives testing on x86_64-linux-gnu.
> 
> Martin
> 



Re: [PATCH, ARM] Clean up arm backend using the @ construct for MD patterns

2018-10-09 Thread Ramana Radhakrishnan
On 09/10/2018 09:27, Mihail Ionescu wrote:
> Hi all,
> 
> This patch removes some of the machine mode checks from the arm backend when
> emitting instructions by using the '@' construct (Parameterized Names[2]). It
> is based on the previous AArch64 patch[1].
> 
> [1]https://gcc.gnu.org/ml/gcc-patches/2018-07/msg00673.html
> [2]https://gcc.gnu.org/onlinedocs/gccint/Parameterized-Names.html#Parameterized-Names
> 
> Ran the tests on arm-none-eabi.

Thanks for the patch - It would be good to split this into 2 patches, 
one for the cleanup with the permute instructions and the other for the 
atomics. That makes life easier with reviews and it's logically grouped 
as well.

Testing on just arm-none-eabi for the atomic_compare_and_swap changes 
are not sufficient. I would prefer a bootstrap and test run on 
arm-none-linux-gnueabihf with (--with-arch=armv7-a --with-fpu=vfpv3-d16 
--with-float=hard as your configure options).

Alternatively I'd be happy if you could ensure that the libraries built 
for arm-none-eabi show no difference in code generation for your change 
? That will give us some more confidence that nothing else is wrong here.



> 
> 
> gcc/ChangeLog:
> 2018-10-03  Mihail 
> Ionescu
> 
>  * config/arm/arm.c (arm_expand_compare_and_swap): Use 
> gen_atomic_compare_and_swap_1
>  instead of explicit mode checks.

Simplify and call gen_atomic_compare_swap_1.

>  (arm_evpc_neon_vuzp): Likewise gen_neon_vuzp_internal.

Simplify and call gen_neon_vuzp_internal..

>  (arm_evpc_neon_vtrn): Likewise gen_neon_vtrn_internal.
>  (arm_evpc_neon_vext): Likewise gen_neon_vext.
>  (arm_evpc_neon_vzip): Likewise gen_neon_vzip_internal.
>  (arm_evpc_neon_vrev): Replaced the function pointer and simplified 
> the mode
>  checks.

and so on...

>  * config/arm/arm.md (neon_vext)
>  (neon_vrev64, neon_vrev32)
>  (neon_vrev16, neon_vtrn_internal)
>  (neon_vzip_internal, neon_vuzp_internal): Add an 
> '@'character
>  before the pattern name.

Separate all pattern names across lines with ,'s .

>  * config/arm/sync.md:
>  (atomic_compare_and_swap_1)
>  (atomic_compare_and_swap_1): Likewise.

Same as above.

> 
> If everything is ok for trunk, can someone commit it on my behalf?
> 
> Best regards,
>  Mihail
> 
> 
> diff.txt
> 
> diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
> index 
> 8810df53aa34798b5e3e1eb3a870101d530702e4..51441efa934f5f2a5963750fcd7e077951406d5a
>  100644
> --- a/gcc/config/arm/arm.c
> +++ b/gcc/config/arm/arm.c
> @@ -28539,8 +28539,7 @@ void
>   arm_expand_compare_and_swap (rtx operands[])
>   {
> rtx bval, bdst, rval, mem, oldval, newval, is_weak, mod_s, mod_f, x;
> -  machine_mode mode;
> -  rtx (*gen) (rtx, rtx, rtx, rtx, rtx, rtx, rtx, rtx);
> +  machine_mode mode, arch_mode;

s/arch_mode/compare_mode

The mode here is the mode for the comparison , whether we use SImode as 
for Thumb1 or a CC_Zmode in !TARGET_THUMB1 cases. arch_mode doesn't tell 
me much on reading the name.

>   
> bval = operands[0];
> rval = operands[1];
> @@ -28588,32 +28587,13 @@ arm_expand_compare_and_swap (rtx operands[])
>   }
>   
> if (TARGET_THUMB1)
> -{
> -  switch (mode)
> - {
> - case E_QImode: gen = gen_atomic_compare_and_swapt1qi_1; break;
> - case E_HImode: gen = gen_atomic_compare_and_swapt1hi_1; break;
> - case E_SImode: gen = gen_atomic_compare_and_swapt1si_1; break;
> - case E_DImode: gen = gen_atomic_compare_and_swapt1di_1; break;
> - default:
> -   gcc_unreachable ();
> - }
> -}
> +arch_mode = E_SImode;
> else
> -{
> -  switch (mode)
> - {
> - case E_QImode: gen = gen_atomic_compare_and_swap32qi_1; break;
> - case E_HImode: gen = gen_atomic_compare_and_swap32hi_1; break;
> - case E_SImode: gen = gen_atomic_compare_and_swap32si_1; break;
> - case E_DImode: gen = gen_atomic_compare_and_swap32di_1; break;
> - default:
> -   gcc_unreachable ();
> - }
> -}
> +arch_mode = CC_Zmode;
>   
> bdst = TARGET_THUMB1 ? bval : gen_rtx_REG (CC_Zmode, CC_REGNUM);
> -  emit_insn (gen (bdst, rval, mem, oldval, newval, is_weak, mod_s, mod_f));
> +  emit_insn (gen_atomic_compare_and_swap_1 (arch_mode, mode, bdst, rval, 
> mem, oldval,
> +  newval, is_weak, mod_s, mod_f));
>   
> if (mode == QImode || mode == HImode)
>   emit_move_insn (operands[1], gen_lowpart (mode, rval));
> @@ -28979,7 +28959,6 @@ arm_evpc_neon_vuzp (struct expand_vec_perm_d *d)
>   {
> unsigned int i, odd, mask, nelt = d->perm.length ();
> rtx out0, out1, in0, in1;
> -  rtx (*gen)(rtx, rtx, rtx, rtx);
> int first_elem;
> int swap_nelt;
>   
> @@ -29013,22 +28992,6 @@ arm_evpc_neon_vuzp (struct expand_vec_perm_d *d)
> if (d->testing_p)
>   return true;
>   
> -  switch (d->vmode)
> -{
> -

Re: [PATCH] Come up with gcc/testsuite/g++.target/i386/i386.dg and move there some tests.

2018-10-09 Thread Martin Liška
Hi.

There's another move of C++ tests, this time these that have dg-require-ifunc.
Key question is whether we want to make subfolders for i386 tests (ext, other, 
..)?

Survives make check -k RUNTESTFLAGS="i386.exp"

Martin
>From d36db4d5b8306dcbe2d63762bc8596e05132e46a Mon Sep 17 00:00:00 2001
From: marxin 
Date: Tue, 9 Oct 2018 10:43:35 +0200
Subject: [PATCH] Move some i386 C++ tests into g++.target/i386.

testsuite/ChangeLog:

2018-10-09  Martin Liska  

	* pr57362.C: Move to g++.target/i386 folder.
	* pr57548.C: Likewise.
	* pr59492.C: Likewise.
	* pr82625.C: Likewise.
	* pr85329-2.C: Likewise.
	* pr85329.C: Likewise.
---
 gcc/testsuite/{g++.dg/ext => g++.target/i386}/pr57362.C   | 2 +-
 gcc/testsuite/{g++.dg/ext => g++.target/i386}/pr57548.C   | 2 +-
 gcc/testsuite/{g++.dg/other => g++.target/i386}/pr59492.C | 2 +-
 gcc/testsuite/{g++.dg/ext => g++.target/i386}/pr82625.C   | 2 +-
 gcc/testsuite/{g++.dg/ext => g++.target/i386}/pr85329-2.C | 2 +-
 gcc/testsuite/{g++.dg/ext => g++.target/i386}/pr85329.C   | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)
 rename gcc/testsuite/{g++.dg/ext => g++.target/i386}/pr57362.C (99%)
 rename gcc/testsuite/{g++.dg/ext => g++.target/i386}/pr57548.C (93%)
 rename gcc/testsuite/{g++.dg/other => g++.target/i386}/pr59492.C (87%)
 rename gcc/testsuite/{g++.dg/ext => g++.target/i386}/pr82625.C (93%)
 rename gcc/testsuite/{g++.dg/ext => g++.target/i386}/pr85329-2.C (81%)
 rename gcc/testsuite/{g++.dg/ext => g++.target/i386}/pr85329.C (80%)

diff --git a/gcc/testsuite/g++.dg/ext/pr57362.C b/gcc/testsuite/g++.target/i386/pr57362.C
similarity index 99%
rename from gcc/testsuite/g++.dg/ext/pr57362.C
rename to gcc/testsuite/g++.target/i386/pr57362.C
index 07270946d55..8c07e857525 100644
--- a/gcc/testsuite/g++.dg/ext/pr57362.C
+++ b/gcc/testsuite/g++.target/i386/pr57362.C
@@ -1,4 +1,4 @@
-/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-do compile } */
 /* { dg-require-ifunc "" }  */
 
 __attribute__((target("default")))
diff --git a/gcc/testsuite/g++.dg/ext/pr57548.C b/gcc/testsuite/g++.target/i386/pr57548.C
similarity index 93%
rename from gcc/testsuite/g++.dg/ext/pr57548.C
rename to gcc/testsuite/g++.target/i386/pr57548.C
index 1cc728d294c..e027f7d432f 100644
--- a/gcc/testsuite/g++.dg/ext/pr57548.C
+++ b/gcc/testsuite/g++.target/i386/pr57548.C
@@ -1,4 +1,4 @@
-/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-do compile } */
 /* { dg-require-ifunc "" }  */
 
 int fum (); // Extra declaration that is merged with the second one.
diff --git a/gcc/testsuite/g++.dg/other/pr59492.C b/gcc/testsuite/g++.target/i386/pr59492.C
similarity index 87%
rename from gcc/testsuite/g++.dg/other/pr59492.C
rename to gcc/testsuite/g++.target/i386/pr59492.C
index 92694ae6dde..25393d7a3c2 100644
--- a/gcc/testsuite/g++.dg/other/pr59492.C
+++ b/gcc/testsuite/g++.target/i386/pr59492.C
@@ -1,4 +1,4 @@
-// { dg-do assemble { target { { i?86-*-* x86_64-*-* } && fpic } } }
+// { dg-do assemble { target { fpic } } }
 // { dg-options "-mx32 -fPIC" }
 // { dg-require-ifunc "" }
 // { dg-require-effective-target maybe_x32 }
diff --git a/gcc/testsuite/g++.dg/ext/pr82625.C b/gcc/testsuite/g++.target/i386/pr82625.C
similarity index 93%
rename from gcc/testsuite/g++.dg/ext/pr82625.C
rename to gcc/testsuite/g++.target/i386/pr82625.C
index 59b174f8c51..0eb70baed5e 100644
--- a/gcc/testsuite/g++.dg/ext/pr82625.C
+++ b/gcc/testsuite/g++.target/i386/pr82625.C
@@ -1,7 +1,7 @@
 /* { dg-do compile } */
 /* { dg-require-ifunc "" } */
 /* { dg-options "-O2 -fdump-tree-optimized" } */
-/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-do compile } */
 
 __attribute__ ((target ("default")))
 static unsigned foo(const char *buf, unsigned size) {
diff --git a/gcc/testsuite/g++.dg/ext/pr85329-2.C b/gcc/testsuite/g++.target/i386/pr85329-2.C
similarity index 81%
rename from gcc/testsuite/g++.dg/ext/pr85329-2.C
rename to gcc/testsuite/g++.target/i386/pr85329-2.C
index 24622d404f7..e58ab4c5955 100644
--- a/gcc/testsuite/g++.dg/ext/pr85329-2.C
+++ b/gcc/testsuite/g++.target/i386/pr85329-2.C
@@ -1,4 +1,4 @@
-/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-do compile } */
 /* { dg-require-ifunc "" } */
 
 class b
diff --git a/gcc/testsuite/g++.dg/ext/pr85329.C b/gcc/testsuite/g++.target/i386/pr85329.C
similarity index 80%
rename from gcc/testsuite/g++.dg/ext/pr85329.C
rename to gcc/testsuite/g++.target/i386/pr85329.C
index fb77e42cd78..4a0ebf29c07 100644
--- a/gcc/testsuite/g++.dg/ext/pr85329.C
+++ b/gcc/testsuite/g++.target/i386/pr85329.C
@@ -1,4 +1,4 @@
-/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-do compile } */
 /* { dg-require-ifunc "" } */
 
 struct a
-- 
2.19.0



Re: [PATCH] Come up with gcc/testsuite/g++.target/i386/i386.dg and move there some tests.

2018-10-09 Thread Rainer Orth
Hi Martin,

> rename from gcc/testsuite/g++.dg/ext/pr82625.C
> rename to gcc/testsuite/g++.target/i386/pr82625.C
> index 59b174f8c51..0eb70baed5e 100644
> --- a/gcc/testsuite/g++.dg/ext/pr82625.C
> +++ b/gcc/testsuite/g++.target/i386/pr82625.C
> @@ -1,7 +1,7 @@
>  /* { dg-do compile } */
>  /* { dg-require-ifunc "" } */
>  /* { dg-options "-O2 -fdump-tree-optimized" } */
> -/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
> +/* { dg-do compile } */

this is wrong: two instances of dg-do and dg-do after target selections
don't play well with one another.  When you added it yesterday, you
badly broke the test on all x86 targets without ifunc support (probably
everything non-Linux):

+UNRESOLVED: g++.dg/ext/pr82625.C  -std=gnu++11  scan-tree-dump-times optimized 
"return 4096;" 1
+UNRESOLVED: g++.dg/ext/pr82625.C  -std=gnu++11  scan-tree-dump-times optimized 
"return 8192;" 1
+FAIL: g++.dg/ext/pr82625.C  -std=gnu++11 (test for excess errors)

Excess errors:
/vol/gcc/src/hg/trunk/local/gcc/testsuite/g++.dg/ext/pr82625.C:7:17: error: 
multiversioning needs ifunc which is not supported on this target
/vol/gcc/src/hg/trunk/local/gcc/testsuite/g++.dg/ext/pr82625.C:24:1: error: use 
of multiversioned function without a default

Just remove the second dg-do line.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: introduce --enable-mingw-full32 to default to --large-address-aware

2018-10-09 Thread JonY
On 10/09/2018 04:59 AM, Alexandre Oliva wrote:
> On Oct  5, 2018, Joseph Myers  wrote:
> 
>> A new configure option needs documenting in install.texi.
> 
> Ah, yes, thanks for the reminder.
> 
> On Oct  6, 2018, JonY <10wa...@gmail.com> wrote:
> 
>> They're both OK as far as I can see. I just don't like the configure
>> name implying all 32bit pointers are used by userspace. Perhaps just
>> --enable-large-address-aware?
> 
> That might suggest the flag affects all targets, including Cygwin, so
> I'm following the existing (undocumented) practice in suggesting
> --enable-mingw-large-address-aware instead.  Please let me know if you'd
> rather not have mingw in the option name, and for it to affect (in the
> --disable form) the Cygwin target as well.
> 

It is fine to turn it on by default in 32bit MinGW (i686-*-mingw*), but
leave the defaults as is for others like Cygwin, I am not too sure of
the effects for Cygwin.

I don't think mingw should be in the configure name as this is
applicable to all Win32 PE targets, it is a PE flag after all.



signature.asc
Description: OpenPGP digital signature


[C++ Patch PING] Re: [C++ Patch] PR 84423 ("[6/7/8/9 Regression] [concepts] ICE with invalid using declaration")

2018-10-09 Thread Paolo Carlini

Hi,

gently pinging the below...

On 29/09/18 21:27, Paolo Carlini wrote:

Hi again,

On 9/28/18 9:15 PM, Paolo Carlini wrote:
Thanks. About the location, you are certainly right, but doesn't seem 
trivial. Something we can do *now* is using 
declspecs->locations[ds_typedef] and declspecs->locations[ds_alias], 
but that gives us the location of the keyword 'typedef' and 'using', 
respectively, whereas I think that we would like to have the location 
of 'auto' itself. I could look into that as a follow-up piece work


In fact, completing the work turned out to be easy: ensure that 
cp_parser_alias_declaration saves the location of the defining-type-id 
too and then consistently use locations[ds_type_spec] in the error 
messages. Tested x86_64-linux. Still Ok? ;)


    https://gcc.gnu.org/ml/gcc-patches/2018-09/msg01773.html

Thanks! Paolo.






Re: [PATCH] Make std::list::iterator == and != global inline friend

2018-10-09 Thread Jonathan Wakely

On 09/10/18 07:25 +0200, François Dumont wrote:
As we talked one day I would like to make all iterator operators 
global for consistency. So here is the patch to do so for std::list 
iterators.


By "global" you mean "non-member", right?



Thanks to this change the operators ==(iterator, const_iterator) and 
!= are not necessary anymore, one less ==|!= operator candidate.


    * include/bits/stl_list.h
    (_List_operator<>::operator==): Make global inline friend.


I find this description a bit confusing. Please use "Replace member
function with inline friend" instead.


    (_List_operator<>::operator!=): Likewise.
    (_List_const_operator<>::operator==): Likewise.
    (_List_const_operator<>::operator!=): Likewise.
    (operator==(const _List_iterator<>&, const _List_const_iterator<>&)):
    Remove.
    (operator!=(const _List_iterator<>&, const _List_const_iterator<>&)):
    Remove.

Tested under Linux x86_64.

Ok to commit ?


OK with the revised changelog text, thanks.




[PATCH] Fix cut&paste fallout

2018-10-09 Thread Richard Biener


Committed as obvious.

Richard.

2018-10-09  Richard Biener  

* tree-vectorizer.c (dump_stmt_cost): Fix cut&paste missing
replacements.

diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c
index 0ab366b79a3..60ee7f6380c 100644
--- a/gcc/tree-vectorizer.c
+++ b/gcc/tree-vectorizer.c
@@ -129,31 +129,31 @@ dump_stmt_cost (FILE *f, void *data, int count, enum 
vect_cost_for_stmt kind,
   ks = "unaligned_store";
   break;
 case vector_store:
-  ks = "unaligned_store";
+  ks = "vector_store";
   break;
 case vector_scatter_store:
-  ks = "unaligned_store";
+  ks = "vector_scatter_store";
   break;
 case vec_to_scalar:
-  ks = "unaligned_store";
+  ks = "vec_to_scalar";
   break;
 case scalar_to_vec:
-  ks = "unaligned_store";
+  ks = "scalar_to_vec";
   break;
 case cond_branch_not_taken:
-  ks = "unaligned_store";
+  ks = "cond_branch_not_taken";
   break;
 case cond_branch_taken:
-  ks = "unaligned_store";
+  ks = "cond_branch_taken";
   break;
 case vec_perm:
-  ks = "unaligned_store";
+  ks = "vec_perm";
   break;
 case vec_promote_demote:
-  ks = "unaligned_store";
+  ks = "vec_promote_demote";
   break;
 case vec_construct:
-  ks = "unaligned_store";
+  ks = "vec_construct";
   break;
 }
   fprintf (f, "%s ", ks);


Re: [PATCH] Come up with gcc/testsuite/g++.target/i386/i386.dg and move there some tests.

2018-10-09 Thread Martin Liška
On 10/9/18 11:03 AM, Rainer Orth wrote:
> Hi Martin,
> 
>> rename from gcc/testsuite/g++.dg/ext/pr82625.C
>> rename to gcc/testsuite/g++.target/i386/pr82625.C
>> index 59b174f8c51..0eb70baed5e 100644
>> --- a/gcc/testsuite/g++.dg/ext/pr82625.C
>> +++ b/gcc/testsuite/g++.target/i386/pr82625.C
>> @@ -1,7 +1,7 @@
>>  /* { dg-do compile } */
>>  /* { dg-require-ifunc "" } */
>>  /* { dg-options "-O2 -fdump-tree-optimized" } */
>> -/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
>> +/* { dg-do compile } */
> 
> this is wrong: two instances of dg-do and dg-do after target selections
> don't play well with one another.  When you added it yesterday, you
> badly broke the test on all x86 targets without ifunc support (probably
> everything non-Linux):
> 
> +UNRESOLVED: g++.dg/ext/pr82625.C  -std=gnu++11  scan-tree-dump-times 
> optimized "return 4096;" 1
> +UNRESOLVED: g++.dg/ext/pr82625.C  -std=gnu++11  scan-tree-dump-times 
> optimized "return 8192;" 1
> +FAIL: g++.dg/ext/pr82625.C  -std=gnu++11 (test for excess errors)
> 
> Excess errors:
> /vol/gcc/src/hg/trunk/local/gcc/testsuite/g++.dg/ext/pr82625.C:7:17: error: 
> multiversioning needs ifunc which is not supported on this target
> /vol/gcc/src/hg/trunk/local/gcc/testsuite/g++.dg/ext/pr82625.C:24:1: error: 
> use of multiversioned function without a default
> 
> Just remove the second dg-do line.

Thanks for testing!

I'm sending updated version of the patch.

Martin

> 
>   Rainer
> 

>From 7e53582805ace4399a77b6dfa1350708ceba06e1 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Tue, 9 Oct 2018 10:43:35 +0200
Subject: [PATCH] Move some i386 C++ tests into g++.target/i386.

testsuite/ChangeLog:

2018-10-09  Martin Liska  

	* pr57362.C: Move to g++.target/i386 folder.
	* pr57548.C: Likewise.
	* pr59492.C: Likewise.
	* pr82625.C: Likewise.
	* pr85329-2.C: Likewise.
	* pr85329.C: Likewise.
---
 gcc/testsuite/{g++.dg/ext => g++.target/i386}/pr57362.C   | 2 +-
 gcc/testsuite/{g++.dg/ext => g++.target/i386}/pr57548.C   | 2 +-
 gcc/testsuite/{g++.dg/other => g++.target/i386}/pr59492.C | 2 +-
 gcc/testsuite/{g++.dg/ext => g++.target/i386}/pr82625.C   | 1 -
 gcc/testsuite/{g++.dg/ext => g++.target/i386}/pr85329-2.C | 2 +-
 gcc/testsuite/{g++.dg/ext => g++.target/i386}/pr85329.C   | 2 +-
 6 files changed, 5 insertions(+), 6 deletions(-)
 rename gcc/testsuite/{g++.dg/ext => g++.target/i386}/pr57362.C (99%)
 rename gcc/testsuite/{g++.dg/ext => g++.target/i386}/pr57548.C (93%)
 rename gcc/testsuite/{g++.dg/other => g++.target/i386}/pr59492.C (87%)
 rename gcc/testsuite/{g++.dg/ext => g++.target/i386}/pr82625.C (93%)
 rename gcc/testsuite/{g++.dg/ext => g++.target/i386}/pr85329-2.C (81%)
 rename gcc/testsuite/{g++.dg/ext => g++.target/i386}/pr85329.C (80%)

diff --git a/gcc/testsuite/g++.dg/ext/pr57362.C b/gcc/testsuite/g++.target/i386/pr57362.C
similarity index 99%
rename from gcc/testsuite/g++.dg/ext/pr57362.C
rename to gcc/testsuite/g++.target/i386/pr57362.C
index 07270946d55..8c07e857525 100644
--- a/gcc/testsuite/g++.dg/ext/pr57362.C
+++ b/gcc/testsuite/g++.target/i386/pr57362.C
@@ -1,4 +1,4 @@
-/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-do compile } */
 /* { dg-require-ifunc "" }  */
 
 __attribute__((target("default")))
diff --git a/gcc/testsuite/g++.dg/ext/pr57548.C b/gcc/testsuite/g++.target/i386/pr57548.C
similarity index 93%
rename from gcc/testsuite/g++.dg/ext/pr57548.C
rename to gcc/testsuite/g++.target/i386/pr57548.C
index 1cc728d294c..e027f7d432f 100644
--- a/gcc/testsuite/g++.dg/ext/pr57548.C
+++ b/gcc/testsuite/g++.target/i386/pr57548.C
@@ -1,4 +1,4 @@
-/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-do compile } */
 /* { dg-require-ifunc "" }  */
 
 int fum (); // Extra declaration that is merged with the second one.
diff --git a/gcc/testsuite/g++.dg/other/pr59492.C b/gcc/testsuite/g++.target/i386/pr59492.C
similarity index 87%
rename from gcc/testsuite/g++.dg/other/pr59492.C
rename to gcc/testsuite/g++.target/i386/pr59492.C
index 92694ae6dde..25393d7a3c2 100644
--- a/gcc/testsuite/g++.dg/other/pr59492.C
+++ b/gcc/testsuite/g++.target/i386/pr59492.C
@@ -1,4 +1,4 @@
-// { dg-do assemble { target { { i?86-*-* x86_64-*-* } && fpic } } }
+// { dg-do assemble { target { fpic } } }
 // { dg-options "-mx32 -fPIC" }
 // { dg-require-ifunc "" }
 // { dg-require-effective-target maybe_x32 }
diff --git a/gcc/testsuite/g++.dg/ext/pr82625.C b/gcc/testsuite/g++.target/i386/pr82625.C
similarity index 93%
rename from gcc/testsuite/g++.dg/ext/pr82625.C
rename to gcc/testsuite/g++.target/i386/pr82625.C
index 59b174f8c51..47bd2df1104 100644
--- a/gcc/testsuite/g++.dg/ext/pr82625.C
+++ b/gcc/testsuite/g++.target/i386/pr82625.C
@@ -1,7 +1,6 @@
 /* { dg-do compile } */
 /* { dg-require-ifunc "" } */
 /* { dg-options "-O2 -fdump-tree-optimized" } */
-/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
 
 __attribute__ ((target ("default")))
 static unsigned foo(const char *buf, unsigned size) {
diff --git a/gcc/testsuite/g++.dg/ex

[PATCH] Help PR63155 PTA hog a bit

2018-10-09 Thread Richard Biener


This helps us throw away constraints from uninitialized stuff earlier.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2018-10-09  Richard Biener  

PR tree-optimization/63155
* tree-ssa-structalias.c: Include tree-ssa.h.
(get_constraint_for_ssa_var): For undefs return nothing_id.
(find_func_aliases): Cleanup PHI handling.

diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 22558351138..06ac0016e03 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -42,6 +42,7 @@
 #include "varasm.h"
 #include "stringpool.h"
 #include "attribs.h"
+#include "tree-ssa.h"
 
 /* The idea behind this analyzer is to generate set constraints from the
program, then solve the resulting constraints in order to generate the
@@ -2928,15 +2929,26 @@ get_constraint_for_ssa_var (tree t, vec *results, 
bool address_p)
   /* We allow FUNCTION_DECLs here even though it doesn't make much sense.  */
   gcc_assert (TREE_CODE (t) == SSA_NAME || DECL_P (t));
 
-  /* For parameters, get at the points-to set for the actual parm
- decl.  */
   if (TREE_CODE (t) == SSA_NAME
-  && SSA_NAME_IS_DEFAULT_DEF (t)
-  && (TREE_CODE (SSA_NAME_VAR (t)) == PARM_DECL
- || TREE_CODE (SSA_NAME_VAR (t)) == RESULT_DECL))
+  && SSA_NAME_IS_DEFAULT_DEF (t))
 {
-  get_constraint_for_ssa_var (SSA_NAME_VAR (t), results, address_p);
-  return;
+  /* For parameters, get at the points-to set for the actual parm
+decl.  */
+  if (TREE_CODE (SSA_NAME_VAR (t)) == PARM_DECL
+ || TREE_CODE (SSA_NAME_VAR (t)) == RESULT_DECL)
+   {
+ get_constraint_for_ssa_var (SSA_NAME_VAR (t), results, address_p);
+ return;
+   }
+  /* For undefined SSA names return nothing.  */
+  else if (!ssa_defined_default_def_p (t))
+   {
+ cexpr.var = nothing_id;
+ cexpr.type = SCALAR;
+ cexpr.offset = 0;
+ results->safe_push (cexpr);
+ return;
+   }
 }
 
   /* For global variables resort to the alias target.  */
@@ -4833,35 +4845,19 @@ find_func_aliases (struct function *fn, gimple *origt)
   gimple *t = origt;
   auto_vec lhsc;
   auto_vec rhsc;
-  struct constraint_expr *c;
   varinfo_t fi;
 
   /* Now build constraints expressions.  */
   if (gimple_code (t) == GIMPLE_PHI)
 {
-  size_t i;
-  unsigned int j;
-
   /* For a phi node, assign all the arguments to
 the result.  */
   get_constraint_for (gimple_phi_result (t), &lhsc);
-  for (i = 0; i < gimple_phi_num_args (t); i++)
+  for (unsigned i = 0; i < gimple_phi_num_args (t); i++)
{
- tree strippedrhs = PHI_ARG_DEF (t, i);
-
- STRIP_NOPS (strippedrhs);
  get_constraint_for_rhs (gimple_phi_arg_def (t, i), &rhsc);
-
- FOR_EACH_VEC_ELT (lhsc, j, c)
-   {
- struct constraint_expr *c2;
- while (rhsc.length () > 0)
-   {
- c2 = &rhsc.last ();
- process_constraint (new_constraint (*c, *c2));
- rhsc.pop ();
-   }
-   }
+ process_all_all_constraints (lhsc, rhsc);
+ rhsc.truncate (0);
}
 }
   /* In IPA mode, we need to generate constraints to pass call


Re: [PATCHv2] Handle not explicitly zero terminated strings in merge sections

2018-10-09 Thread Rainer Orth
Hi Eric,

>> Besides, the patch seems to have produced more fallout on Solaris: I see
>> many new Go testsuite failures on Solaris 10 which probably are related,
>> and Solaris bootstrap with Ada included is broken due to the extended
>> usage of string merging.  I'm currently investigating what's going on
>> there.
>
> I can bootstrap on SPARC/Solaris 10 and 11 (GNU as and system linker) but I 
> have regressions on Solaris 11 (and not 10) under the form of SIGBUSes:

I could bootstrap on Solaris/SPARC with Bernd's patch, too.  The
bootstrap failure only occured on Solaris 11/x86 with gas.

Which version exactly (pkg list entire) of Solaris 11 are you running?
I'm using gas 2.31 and /bin/ld on Solaris 11.4 resp. 11.5 Beta, where
Bernd's patch in PR bootstrap/87551 fixed the remaining regressions.

> === acats tests ===
> FAIL:   c34005g
> FAIL:   c35508c
> FAIL:   ce3602d
> FAIL:   cxa4005
> FAIL:   ee3412c
>
> FAIL: gfortran.dg/allocatable_function_5.f90   -O1  execution test
> FAIL: gfortran.dg/allocatable_function_5.f90   -O2  execution test
> FAIL: gfortran.dg/allocatable_function_5.f90   -O3 -fomit-frame-pointer -
> funroll-loops -fpeel-loops -ftracer -finline-functions  execution test
> FAIL: gfortran.dg/allocatable_function_5.f90   -O3 -g  execution test
> FAIL: gfortran.dg/allocatable_function_5.f90   -Os  execution test
> FAIL: gfortran.dg/char_allocation_1.f90   -O1  (test for excess errors)
> UNRESOLVED: gfortran.dg/char_allocation_1.f90   -O1  compilation failed to 
> produce executable
> FAIL: gfortran.dg/char_allocation_1.f90   -O2  (test for excess errors)
> UNRESOLVED: gfortran.dg/char_allocation_1.f90   -O2  compilation failed to 
> produce executable
> FAIL: gfortran.dg/char_allocation_1.f90   -O3 -fomit-frame-pointer -funroll-
> loops -fpeel-loops -ftracer -finline-functions  (test for excess errors)
> UNRESOLVED: gfortran.dg/char_allocation_1.f90   -O3 -fomit-frame-pointer -
> funroll-loops -fpeel-loops -ftracer -finline-functions  compilation failed to 
> produce executable
> FAIL: gfortran.dg/char_allocation_1.f90   -O3 -g  (test for excess errors)
> UNRESOLVED: gfortran.dg/char_allocation_1.f90   -O3 -g  compilation failed to 
> produce executable

Those are fixed by the patch in PR bootstrap/87551...

> FAIL: gfortran.dg/char_pointer_assign_3.f90   -O2  execution test
> FAIL: gfortran.dg/char_pointer_assign_3.f90   -O3 -fomit-frame-pointer -
> funroll-loops -fpeel-loops -ftracer -finline-functions  execution test
> FAIL: gfortran.dg/char_pointer_assign_3.f90   -O3 -g  execution test
> FAIL: gfortran.dg/implied_do_io_2.f90   -Os  execution test
> FAIL: gfortran.dg/namelist_38.f90   -O2  execution test
> FAIL: gfortran.dg/namelist_38.f90   -O3 -fomit-frame-pointer -funroll-loops -
> fpeel-loops -ftracer -finline-functions  execution test
> FAIL: gfortran.dg/namelist_38.f90   -O3 -g  execution test
> FAIL: gfortran.dg/namelist_70.f90   -O1  execution test
> FAIL: gfortran.dg/namelist_70.f90   -O2  execution test
> FAIL: gfortran.dg/namelist_70.f90   -O3 -fomit-frame-pointer -funroll-loops -
> fpeel-loops -ftracer -finline-functions  execution test
> FAIL: gfortran.dg/namelist_70.f90   -O3 -g  execution test
> FAIL: gfortran.dg/namelist_70.f90   -Os  execution test
> FAIL: gfortran.dg/nan_6.f90   -O1  execution test
> FAIL: gfortran.dg/realloc_on_assign_4.f03   -O1  execution test
> FAIL: gfortran.dg/realloc_on_assign_4.f03   -O2  execution test
> FAIL: gfortran.dg/realloc_on_assign_4.f03   -O3 -fomit-frame-pointer -funroll-
> loops -fpeel-loops -ftracer -finline-functions  execution test
> FAIL: gfortran.dg/realloc_on_assign_4.f03   -O3 -g  execution test
> FAIL: gfortran.dg/realloc_on_assign_4.f03   -Os  execution test
> FAIL: gfortran.dg/streamio_14.f90   -O2  execution test
> FAIL: gfortran.dg/streamio_14.f90   -O3 -fomit-frame-pointer -funroll-loops -
> fpeel-loops -ftracer -finline-functions  execution test
> FAIL: gfortran.dg/streamio_14.f90   -O3 -g  execution test

> FAIL: gfortran.dg/substr_7.f90   -O  (test for excess errors)
> UNRESOLVED: gfortran.dg/substr_7.f90   -O  compilation failed to produce 
> executable

... as is this one.

> FAIL: gfortran.dg/widechar_2.f90   -O1  execution test
> FAIL: gfortran.dg/widechar_2.f90   -Os  execution test
> FAIL: gfortran.fortran-torture/execute/adjustr.f90 execution,  -Os

> FAIL: go.test/test/fixedbugs/issue4562.go execution,  -O2 -g 
> FAIL: go.test/test/nil.go execution,  -O2 -g

These two were present before Bernd's patch.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


[PATCH] Fix setting of hotness in non-LTO mode (PR gcov-profile/77698).

2018-10-09 Thread Martin Liška
Hi.

In non-LTO mode, we should not set hotness according to computed histogram
in ipa-profile. Following patch does that and fixes the test-case isolated
from PR.

Patch survives regression tests on x86_64-linux-gnu.
Ready for trunk?
Thanks,
Martin

gcc/ChangeLog:

2018-10-09  Martin Liska  

PR gcov-profile/77698
* ipa-profile.c (ipa_profile): Adjust hotness threshold
only in LTO mode.

gcc/testsuite/ChangeLog:

2018-10-09  Martin Liska  

PR gcov-profile/77698
* gcc.dg/tree-prof/pr77698.c: New test.
---
 gcc/ipa-profile.c|  5 ++---
 gcc/testsuite/gcc.dg/tree-prof/pr77698.c | 23 +++
 2 files changed, 25 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/tree-prof/pr77698.c


diff --git a/gcc/ipa-profile.c b/gcc/ipa-profile.c
index c74f4a4a41d..7065af59ba9 100644
--- a/gcc/ipa-profile.c
+++ b/gcc/ipa-profile.c
@@ -533,11 +533,10 @@ ipa_profile (void)
 		   cumulated_size * 100.0 / overall_size);
 	}
 
-  if (threshold > get_hot_bb_threshold ()
-	  || in_lto_p)
+  if (in_lto_p)
 	{
 	  if (dump_file)
-	fprintf (dump_file, "Threshold updated.\n");
+	fprintf (dump_file, "Setting hotness threshold in LTO mode.\n");
   set_hot_bb_threshold (threshold);
 	}
 }
diff --git a/gcc/testsuite/gcc.dg/tree-prof/pr77698.c b/gcc/testsuite/gcc.dg/tree-prof/pr77698.c
new file mode 100644
index 000..201bfc7ee20
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-prof/pr77698.c
@@ -0,0 +1,23 @@
+/* { dg-options "-O2 -fno-tree-vectorize -funroll-loops --param max-unroll-times=4 -fno-inline -fdump-rtl-alignments" } */
+
+volatile long int g;
+volatile long int j = 0;
+
+void foo(long int *a, long int *b, long int n)
+{
+  long int i;
+
+  for (i = 0; i < n; i++)
+a[j] = *b;
+}
+
+long int a, b;
+int main()
+{
+  a = 1; b = 2;
+  foo(&a, &b, 100);
+  g = a+b;
+  return 0;
+}
+
+/* { dg-final-use-not-autofdo { scan-rtl-dump-times "internal loop alignment added" 1 "alignments"} } */



RE: [PATCH][GCC][mid-end] Add a hook to support telling the mid-end when to probe the stack [patch (2/6)]

2018-10-09 Thread Tamar Christina
Hi Richard,

> -Original Message-
> From: Richard Biener 
> Sent: Tuesday, October 9, 2018 08:28
> To: Tamar Christina 
> Cc: Jeff Law ; gcc-patches@gcc.gnu.org; nd
> ; i...@airs.com
> Subject: RE: [PATCH][GCC][mid-end] Add a hook to support telling the mid-
> end when to probe the stack [patch (2/6)]
> 
> On Tue, 9 Oct 2018, Tamar Christina wrote:
> 
> > Hi All,
> >
> > I'm looking for permission to backport this patch to the GCC-8 branch
> > to fix PR86486.
> >
> > OK for backport?
> 
> This doesn't seem to fix a regression and it's been on trunk only for a few
> days.

I probably should have asked for the backport on patch 0/8 instead of 
individually.

But the reason for asking for the backport is that on GCC-8 the current 
implementation is insufficient for AArch64.
The only protection a user would get from turning on stack-clash protection 
would be from the mid-end alloca code.
static allocations and SVE code would get zero protection.

The changes, including the mid-end changes don't affect any other target. The 
mid-end change is gated by a target hook
that only aarch64 defines.

I'm happy to let it sit on trunk a bit longer for more testing if that's what's 
required or to test against more targets.

The current patch set was tested trunk on x86_64 and AArch64 by comparing

 a) builds with stack-clash off (with patches vs w/o patches) and
 b) builds with stack-clash on (with patches vs w/o patches).
 
For AArch64 the glibc testsuite was also ran (with patches vs w/o patches) with 
stack-clash on.

The patches apply almost cleanly on GCC-8, modulo some small conflicts like 
line numbers in configure file and removal of some
minor features not available in GCC-8.

So far the GCC-8 version I have only done a bootstrap and regression with 
stack-clash on by default on AArch64.  I am planning
more testing on AArch64 and x86_64 but wanted to check on the backport before 
doing the exhaustive testing.

I believe a backport of only the target specific bits may also be sufficient to 
give protection, but have not worked
through this scenario yet.  It's not the preferred option but one that I'd be 
happy to investigate if it's the only one available.

Regards,
Tamar

> 
> Richard.
> 
> > Thanks,
> > Tamar
> >
> > > -Original Message-
> > > From: Jeff Law 
> > > Sent: Wednesday, July 11, 2018 19:53
> > > To: Tamar Christina ;
> > > gcc-patches@gcc.gnu.org
> > > Cc: nd ; rguent...@suse.de; i...@airs.com
> > > Subject: Re: [PATCH][GCC][mid-end] Add a hook to support telling the
> > > mid- end when to probe the stack [patch (2/6)]
> > >
> > > On 07/11/2018 05:21 AM, Tamar Christina wrote:
> > > > Hi All,
> > > >
> > > > This patch adds a hook to tell the mid-end about the probing
> > > > requirements of the target.  On AArch64 we allow a specific range
> > > > for which no probing needs to be done.  This same range is also
> > > > the amount that will have to be probed up when a probe is needed
> > > > after dropping the
> > > stack.
> > > >
> > > > Defining this probe comes with the extra requirement that the
> > > > outgoing arguments size of any function that uses alloca and stack
> > > > clash be at the very least 8 bytes.  With this invariant we can
> > > > skip doing the zero checks for alloca and save some code.
> > > >
> > > > A simplified version of the AArch64 stack frame is:
> > > >
> > > >+---+
> > > >|   |
> > > >|   |
> > > >|   |
> > > >+---+
> > > >|LR |
> > > >+---+
> > > >|FP |
> > > >+---+
> > > >|dynamic allocations| -\  probe range hook effects these
> > > >+---+   --\   and ensures that outgoing stack
> > > >|padding|  -- args is always > 8 when alloca.
> > > >+---+  ---/   Which means it's always safe to 
> > > > probe
> > > >|outgoing stack args|-/   at SP
> > > >+---+
> > > >
> > > >
> > > > This allows us to generate better code than without the hook
> > > > without affecting other targets.
> > > >
> > > > With this patch I am also removing the
> > > > stack_clash_protection_final_dynamic_probe
> > > > hook which was added specifically for AArch64 but that is no longer
> needed.
> > > >
> > > > Bootstrapped Regtested on aarch64-none-linux-gnu,
> > > > x86_64-pc-linux-gnu
> > > and no issues.
> > > > Both targets were tested with stack clash on and off by default.
> > > >
> > > > Ok for trunk?
> > > >
> > > > Thanks,
> > > > Tamar
> > > >
> > > > gcc/
> > > > 2018-07-11  Tamar Christina  
> > > >
> > > > PR target/86486
> > > > * explow.c (anti_adjust_stack_and_probe_stack_clash): Support
> > > custom
> > > > probe ranges.
> > > > * target.def (stack_clash_protection_alloca_probe_range): New.
> > > > 

Re: [PATCHv2] Handle not explicitly zero terminated strings in merge sections

2018-10-09 Thread Bernd Edlinger
On 10/03/18 18:31, Jeff Law wrote:
>> -  && (len = int_size_in_bytes (TREE_TYPE (decl))) > 0
>> -  && TREE_STRING_LENGTH (decl) >= len)
>> +  && (len = int_size_in_bytes (TREE_TYPE (decl))) >= 0
>> +  && TREE_STRING_LENGTH (decl) == len)
> Not sure why you want to test for >= 0 here.  > 0 seems sufficient,
> though I guess there's no harm in the = 0 case.
> 

Aehm, cough...

Sorry Jeff, I need to change that back.  It turns out that
completely empty strings don't work right, because of this
check in output_constant:

output_constant (tree exp, unsigned HOST_WIDE_INT size, unsigned int align,
  bool reverse, bool merge_strings)
{
   enum tree_code code;
   unsigned HOST_WIDE_INT thissize;
   rtx cst;

   if (size == 0 || flag_syntax_only)
 return size;

So while my intention was to add a null-termination for all strings, including 
empty ones,
this does not work for empty strings, which was diagnosed by the solaris 
assembler/linker.

However since those empty strings do not use any space, there is no improvement
by merging them in the first place.


Rainer bootstrapped the attached patch successfully.
Is it OK for trunk?


Thanks
Bernd.
2018-10-09  Bernd Edlinger  

	* varasm.c (mergeable_string_section): Don't try to move zero-length
	strings to the merge section.

Index: gcc/varasm.c
===
--- gcc/varasm.c	(revision 264887)
+++ gcc/varasm.c	(working copy)
@@ -804,7 +804,7 @@ mergeable_string_section (tree decl ATTRIBUTE_UNUS
   && TREE_CODE (decl) == STRING_CST
   && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
   && align <= 256
-  && (len = int_size_in_bytes (TREE_TYPE (decl))) >= 0
+  && (len = int_size_in_bytes (TREE_TYPE (decl))) > 0
   && TREE_STRING_LENGTH (decl) == len)
 {
   scalar_int_mode mode;


Re: [PATCHv2] Handle not explicitly zero terminated strings in merge sections

2018-10-09 Thread Rainer Orth
Hi Bernd,

>> * The merge-all-constants-2.c test doesn't FAIL on Solaris/SPARC with
>>/bin/as, although it lacks string merging support, too.  The assembler
>>output contains
>> 
>>  .section".rodata"
>> 
>>so the pattern currently used to check for .rodata is too
>>restrictive.  There is assembler syntax beyond gas on x86 ;-)
>> 
>
> For the test that failed with the quotes around .rodata.  I think
> instead of looking for a end of line immediately after .rodata, it
> would be sufficient to make sure it does not continue with .str, so
> could you please try to add something like the following to your patch?
>
> Index: gcc/testsuite/gcc.dg/merge-all-constants-2.c
> ===
> --- gcc/testsuite/gcc.dg/merge-all-constants-2.c  (revision 264888)
> +++ gcc/testsuite/gcc.dg/merge-all-constants-2.c  (working copy)
> @@ -5,4 +5,4 @@
>   const char str2[37] = "0123456789abcdefghijklmnopqrstuvwxyz";
>   const char str3[10] = "0123456789abcdefghijklmnopqrstuvwxyz";
>   
> -/* { dg-final { scan-assembler-not "\\.rodata\[\n\r\]" } } */
> +/* { dg-final { scan-assembler-not "\\.rodata\[^.]" } } */

to do this; I've temporarily disabled the string_merging requirement in
the test and ran it on sparc-sun-solaris2.11:

* With as (no string merging), there's

.section".rodata"

  in the output and I get the expected

FAIL: gcc.dg/merge-all-constants-2.c scan-assembler-not \\.rodata[^.]

* With gas however (string merging supported), the output has the usual

.section.rodata.str1.8,"aMS",@progbits,1

  and the test PASSes.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


[PATCH] Define std::string and related typedefs outside __cxx11 namespace

2018-10-09 Thread Jonathan Wakely

The typedefs for common specializations of std::__cxx11::basic_string do
not need to be in the std::__cxx11 namespace. Those typedefs are never
used for linkage purposes so don't appear in mangled names, and so don't
need to be distinct from the equivalent typedefs for the COW
std::basic_string specializations. It is OK for the same typedef to
refer to different types in different translation units.

Defining them directly in namespace std improves diagnostics that use
those typedefs. For example:

error: could not convert '1' from 'int' to 'std::__cxx11::string' {aka 
'std::__cxx11::basic_string'}

will now be printed as:

error: could not convert '1' from 'int' to 'std::string' {aka 
'std::__cxx11::basic_string'}

The precise type is still shown, but the typedef is not obfuscated with
the inline namespace.

* include/bits/stringfwd.h (string, wstring, u16string, u32string):
Define typedefs outside of __cxx11 inline namespace.
* python/libstdcxx/v6/printers.py (register_type_printers): Also
register printers for typedefs in new location.

Tested x86_64-linux, committed to trunk.


commit ee47efe7b3620fcfd3d65548e027523ca26a3615
Author: Jonathan Wakely 
Date:   Tue Oct 9 12:19:29 2018 +0100

Define std::string and related typedefs outside __cxx11 namespace

The typedefs for common specializations of std::__cxx11::basic_string do
not need to be in the std::__cxx11 namespace. Those typedefs are never
used for linkage purposes so don't appear in mangled names, and so don't
need to be distinct from the equivalent typedefs for the COW
std::basic_string specializations. It is OK for the same typedef to
refer to different types in different translation units.

Defining them directly in namespace std improves diagnostics that use
those typedefs. For example:

error: could not convert '1' from 'int' to 'std::__cxx11::string' {aka 
'std::__cxx11::basic_string'}

will now be printed as:

error: could not convert '1' from 'int' to 'std::string' {aka 
'std::__cxx11::basic_string'}

The precise type is still shown, but the typedef is not obfuscated with
the inline namespace.

* include/bits/stringfwd.h (string, wstring, u16string, u32string):
Define typedefs outside of __cxx11 inline namespace.
* python/libstdcxx/v6/printers.py (register_type_printers): Also
register printers for typedefs in new location.

diff --git a/libstdc++-v3/include/bits/stringfwd.h 
b/libstdc++-v3/include/bits/stringfwd.h
index 15eb7183633..2b7f4612cbc 100644
--- a/libstdc++-v3/include/bits/stringfwd.h
+++ b/libstdc++-v3/include/bits/stringfwd.h
@@ -69,6 +69,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
typename _Alloc = allocator<_CharT> >
 class basic_string;
 
+_GLIBCXX_END_NAMESPACE_CXX11
+
   /// A string of @c char
   typedef basic_stringstring;   
 
@@ -85,8 +87,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   typedef basic_string u32string; 
 #endif
 
-_GLIBCXX_END_NAMESPACE_CXX11
-
   /** @}  */
 
 _GLIBCXX_END_NAMESPACE_VERSION
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py 
b/libstdc++-v3/python/libstdcxx/v6/printers.py
index afe1b325d87..827c87b70ea 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -1556,6 +1556,8 @@ def register_type_printers(obj):
 # Add type printers for typedefs std::string, std::wstring etc.
 for ch in ('', 'w', 'u16', 'u32'):
 add_one_type_printer(obj, 'basic_string', ch + 'string')
+add_one_type_printer(obj, '__cxx11::basic_string', ch + 'string')
+# Typedefs for __cxx11::basic_string used to be in namespace __cxx11:
 add_one_type_printer(obj, '__cxx11::basic_string',
  '__cxx11::' + ch + 'string')
 add_one_type_printer(obj, 'basic_string_view', ch + 'string_view')
@@ -1568,7 +1570,7 @@ def register_type_printers(obj):
 for x in ('stringbuf', 'istringstream', 'ostringstream',
   'stringstream'):
 add_one_type_printer(obj, 'basic_' + x, ch + x)
-#  types are in __cxx11 namespace, but typedefs aren'x:
+#  types are in __cxx11 namespace, but typedefs aren't:
 add_one_type_printer(obj, '__cxx11::basic_' + x, ch + x)
 
 # Add type printers for typedefs regex, wregex, cmatch, wcmatch etc.


[gomp5] Fix handling of task_reduction with variable length array sections

2018-10-09 Thread Jakub Jelinek
Hi!

As the following testcase additions show, even the TYPE_MAX_VALUE var needs
to be forced into temporary if it is a user variable, otherwise if that
variable is changed by the user before taskgroup ends, we don't handle it
correctly.

In addition to that, this patch removes useless NULL second argument from
create_tmp_var, forgot we do have a default argument here.

Tested on x86_64-linux, committed to gomp-5_0-branch.

2018-10-09  Jakub Jelinek  

* omp-low.c (lower_omp_task_reductions): Force TYPE_MAX_VALUE into
a temporary in the start sequence and even when it is a decl already.

* omp-low.c (lower_rec_input_clauses, lower_reduction_clauses,
lower_omp_task_reductions): Remove second argument create_tmp_var
if it is NULL.
* gimplify.c (gimplify_omp_depend): Likewise.

* testsuite/libgomp.c-c++-common/task-reduction-5.c: Add further test
to verify the array bound var can be changed in taskgroup.

--- gcc/omp-low.c.jj2018-10-08 17:30:42.147353172 +0200
+++ gcc/omp-low.c   2018-10-09 14:19:54.672380754 +0200
@@ -4091,7 +4091,7 @@ lower_rec_input_clauses (tree clauses, g
  gimple_seq_add_stmt (ilist, g);
}
 
- tree y1 = create_tmp_var (ptype, NULL);
+ tree y1 = create_tmp_var (ptype);
  gimplify_assign (y1, y, ilist);
  tree i2 = NULL_TREE, y2 = NULL_TREE;
  tree body2 = NULL_TREE, end2 = NULL_TREE;
@@ -4102,14 +4102,14 @@ lower_rec_input_clauses (tree clauses, g
 size_int (task_reduction_cnt_full
   + task_reduction_cntorig - 1),
 NULL_TREE, NULL_TREE);
- y3 = create_tmp_var (ptype, NULL);
+ y3 = create_tmp_var (ptype);
  gimplify_assign (y3, ref, ilist);
}
  else if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) || is_simd)
{
  if (pass != 3)
{
- y2 = create_tmp_var (ptype, NULL);
+ y2 = create_tmp_var (ptype);
  gimplify_assign (y2, y, ilist);
}
  if (is_simd || OMP_CLAUSE_REDUCTION_OMP_ORIG_REF (c))
@@ -4126,23 +4126,23 @@ lower_rec_input_clauses (tree clauses, g
  if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c)
  && OMP_CLAUSE_REDUCTION_OMP_ORIG_REF (c))
{
- y3 = create_tmp_var (ptype, NULL);
+ y3 = create_tmp_var (ptype);
  gimplify_assign (y3, unshare_expr (ref), ilist);
}
  if (is_simd)
{
- y4 = create_tmp_var (ptype, NULL);
+ y4 = create_tmp_var (ptype);
  gimplify_assign (y4, ref, dlist);
}
}
}
- tree i = create_tmp_var (TREE_TYPE (v), NULL);
+ tree i = create_tmp_var (TREE_TYPE (v));
  gimplify_assign (i, build_int_cst (TREE_TYPE (v), 0), ilist);
  tree body = create_artificial_label (UNKNOWN_LOCATION);
  gimple_seq_add_stmt (ilist, gimple_build_label (body));
  if (y2)
{
- i2 = create_tmp_var (TREE_TYPE (v), NULL);
+ i2 = create_tmp_var (TREE_TYPE (v));
  gimplify_assign (i2, build_int_cst (TREE_TYPE (v), 0), dlist);
  body2 = create_artificial_label (UNKNOWN_LOCATION);
  end2 = create_artificial_label (UNKNOWN_LOCATION);
@@ -5603,7 +5603,7 @@ lower_reduction_clauses (tree clauses, g
  tree d = OMP_CLAUSE_DECL (c);
  tree type = TREE_TYPE (d);
  tree v = TYPE_MAX_VALUE (TYPE_DOMAIN (type));
- tree i = create_tmp_var (TREE_TYPE (v), NULL);
+ tree i = create_tmp_var (TREE_TYPE (v));
  tree ptype = build_pointer_type (TREE_TYPE (type));
  tree bias = TREE_OPERAND (d, 1);
  d = TREE_OPERAND (d, 0);
@@ -5667,10 +5667,10 @@ lower_reduction_clauses (tree clauses, g
}
  new_var = fold_convert_loc (clause_loc, ptype, new_var);
  ref = fold_convert_loc (clause_loc, ptype, ref);
- tree m = create_tmp_var (ptype, NULL);
+ tree m = create_tmp_var (ptype);
  gimplify_assign (m, new_var, stmt_seqp);
  new_var = m;
- m = create_tmp_var (ptype, NULL);
+ m = create_tmp_var (ptype);
  gimplify_assign (m, ref, stmt_seqp);
  ref = m;
  gimplify_assign (i, build_int_cst (TREE_TYPE (v), 0), stmt_seqp);
@@ -6896,22 +6896,24 @@ lower_omp_task_reductions (omp_context *
{
  tree type = TREE_TYPE (new_var);
  tree v = TYPE_MAX_VALUE (TYPE_DOMAIN 

Re: [PATCH][i386] Split reductions (was: Re: [PATCH][RFC][i386] Change sminmax reduction patterns)

2018-10-09 Thread Richard Biener
On Mon, 8 Oct 2018, Richard Biener wrote:

> On Fri, 5 Oct 2018, Uros Bizjak wrote:
> 
> > On Thu, Oct 4, 2018 at 2:05 PM Richard Biener  wrote:
> > >
> > >
> > > This tries to apply the same trick to sminmax reduction patterns
> > > as for the reduc_plus_scal ones, namely reduce %zmm -> %ymm -> %xmm
> > > first.  On a microbenchmark this improves performance on Zen
> > > by ~30% for AVX2 and on Skylake-SP by ~10% for AVX512 (for AVX2
> > > there's no measurable difference).
> > >
> > > I guess I'm mostly looking for feedback on the approach I took
> > > in not rewriting ix86_expand_reduc but instead "recurse" on the
> > > expanders as well as the need to define recursion stops for
> > > SSE modes previously not covered.
> > >
> > > I'll throw this on a bootstrap & regtest on x86_64-unknown-linux-gnu
> > > later.
> > >
> > > Any comments sofar?  Writing .md patterns is new for me ;)
> > 
> > LGTM for the implementation.
> 
> So this applies the method to all AVX2/AVX512 reduc_*_scal_* patterns
> we have.  I've inspected the assembly and it looks as expected.
> 
> Note I tried relying on the vectorizer to perform this, thus delete
> the patterns.  Trying that for the reduc_plus_* ones reveals that
> the final (SSE width) reduction step looks different and
> unconditionally uses psrldq as the vectorizer expands the final
> reduction step using whole-vector shifts.  Well, it actually
> generates permutes like
> 
>   vect_res_6.10_22 = VEC_PERM_EXPR <_21, { 0.0, 0.0, 0.0, 0.0 }, { 2, 3, 
> 4, 5 }>;
> 
> but those end up using the vec_shr_ expander which puns
> everything to V1TImode.  Removing the vec_shr_ expander
> also doesn't get us the desired movhlps instruction for the
> above (but a vshufps).  I'm not sure where to best fix that
> (I think with good vec_perm expanders we shouldn't neeed the
> vec_shr one - at least we'd keep the float/int domain), so I
> kept all the reduc_* expanders we have now.  But I'll note
> those we do not have (luckily all non-FP) use that
> "inefficient"(?) instructions.  Like on Zen psrldq has a reciprocal
> throughput of 1 while movhlps has one of 0.5, so using movhlps
> would help loops with two reductions, on Skylake the opposite
> seems to be the case...
> 
> Boostrapped on x86_64-unknown-linux-gnu, testing in progress.

Went fine after fixing ...

> @@ -2585,9 +2556,14 @@ (define_expand "reduc__scal_
>   (match_operand:VI_256 1 "register_operand"))]
>"TARGET_AVX2"
>  {
> -  rtx tmp = gen_reg_rtx (mode);
> -  ix86_expand_reduc (gen_3, tmp, operands[1]);
> -  emit_insn (gen_vec_extract (operands[0], tmp,
> +  rtx tmp = gen_reg_rtx (mode);
> +  emit_insn (gen_vec_extract_hi_ (tmp, operands[1]));
> +  rtx tmp2 = gen_reg_rtx (mode);
> +  emit_insn (gen_3
> +(tmp2, tmp, gen_lowpart (mode, operands[1])));
> +  rtx tmp3 = gen_reg_rtx (mode);
 ^^^

> +  ix86_expand_reduc (gen_3, tmp3, tmp2);
> +  emit_insn (gen_vec_extract (operands[0], tmp3,
^^^

to use the proper mode (fixed patch re-attached below).

OK?

Richard.

2018-10-08  Richard Biener  

* config/i386/sse.md (reduc_plus_scal_v8df, reduc_plus_scal_v4df,
reduc_plus_scal_v2df, reduc_plus_scal_v16sf, reduc_plus_scal_v8sf,
reduc_plus_scal_v4sf): Merge into pattern reducing to half width
and recursing and pattern terminating the recursion on SSE
vector width using ix86_expand_reduc.
(reduc_sminmax_scal_): Split into part reducing to half
width and recursing and SSE2 vector variant doing the final
reduction with ix86_expand_reduc.
(reduc_uminmax_scal_): Likewise for the AVX512 variants
with terminating the recursion at AVX level, splitting that
to SSE there.

diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
index 692959b1666..9fc5819a863 100644
--- a/gcc/config/i386/sse.md
+++ b/gcc/config/i386/sse.md
@@ -2457,98 +2457,65 @@
(set_attr "prefix_rep" "1,*")
(set_attr "mode" "V4SF")])
 
-(define_expand "reduc_plus_scal_v8df"
-  [(match_operand:DF 0 "register_operand")
-   (match_operand:V8DF 1 "register_operand")]
-  "TARGET_AVX512F"
-{
-  rtx tmp = gen_reg_rtx (V8DFmode);
-  ix86_expand_reduc (gen_addv8df3, tmp, operands[1]);
-  emit_insn (gen_vec_extractv8dfdf (operands[0], tmp, const0_rtx));
-  DONE;
-})
+(define_mode_iterator REDUC_SSE_PLUS_MODE
+ [(V2DF "TARGET_SSE") (V4SF "TARGET_SSE")])
 
-(define_expand "reduc_plus_scal_v4df"
-  [(match_operand:DF 0 "register_operand")
-   (match_operand:V4DF 1 "register_operand")]
-  "TARGET_AVX"
+(define_expand "reduc_plus_scal_"
+ [(plus:REDUC_SSE_PLUS_MODE
+   (match_operand: 0 "register_operand")
+   (match_operand:REDUC_SSE_PLUS_MODE 1 "register_operand"))]
+ ""
 {
-  rtx tmp = gen_reg_rtx (V2DFmode);
-  emit_insn (gen_vec_extract_hi_v4df (tmp, operands[1]));
-  rtx tmp2 = gen_reg_rtx (V2DFmode);
-  emit_insn (gen_addv2df3 (tmp2, tmp, gen_lowpart (V2DFmode, operands[1])));
-  rtx tmp3 = gen_reg_rtx (V2DFmode);
-  emit_insn (gen_vec_interleave_highv2df (tmp3, tmp2, t

Re: [PATCH] v2: C++: suggestions for misspelled private members (PR c++/84993)

2018-10-09 Thread David Malcolm
On Mon, 2018-09-24 at 10:56 -0600, Martin Sebor wrote:
> On 09/21/2018 04:09 PM, David Malcolm wrote:
> > This is v2 of the patch; I managed to bit-rot my own patch due to
> > my
> > fix for r264335, which tightened up the "is this meaningful"
> > threshold
> > on edit distances when finding spelling correction candidates.
> > 
> > The only change in this version is to rename various things in
> > the testcase so that they continue to be suggested
> > ("colour" vs "m_color" are no longer near enough, so I renamed
> > "colour" to "m_colour").
> > 
> > Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
> > 
> > OK for trunk?
> > 
> > Blurb from v1:
> > 
> > PR c++/84993 identifies a problem with our suggestions for
> > misspelled member names in the C++ FE for the case where the
> > member is private.
> > 
> > For example, given:
> > 
> > class foo
> > {
> > public:
> >   double get_ratio() const { return m_ratio; }
> > 
> > private:
> >   double m_ratio;
> > };
> > 
> > void test(foo *ptr)
> > {
> >   if (ptr->ratio >= 0.5)
> > ;// etc
> > }
> > 
> > ...we currently emit this suggestion:
> > 
> > : In function 'void test(foo*)':
> > :12:12: error: 'class foo' has no member named 'ratio'; did
> > you mean 'm_ratio'?
> >if (ptr->ratio >= 0.5)
> > ^
> > m_ratio
> > 
> > ...but if the user follows this suggestion, they get:
> > 
> > : In function 'void test(foo*)':
> > :12:12: error: 'double foo::m_ratio' is private within this
> > context
> >if (ptr->m_ratio >= 0.5)
> > ^~~
> > :7:10: note: declared private here
> >double m_ratio;
> >   ^~~
> > :12:12: note: field 'double foo::m_ratio' can be accessed
> > via 'double foo::get_ratio() const'
> >if (ptr->m_ratio >= 0.5)
> > ^~~
> > get_ratio()
> > 
> > It feels wrong to be emitting a fix-it hint that doesn't compile,
> > so this
> > patch adds the accessor fix-it hint logic to this case, so that we
> > directly
> > offer a valid suggestion:
> > 
> > : In function 'void test(foo*)':
> > :12:12: error: 'class foo' has no member named 'ratio'; did
> > you mean
> > 'double foo::m_ratio'? (accessible via 'double foo::get_ratio()
> > const')
> >if (ptr->ratio >= 0.5)
> > ^
> > get_ratio()
> 
> I wonder if suggesting the inaccessible member is at all helpful
> if it cannot be used.  

Of the two members "m_ratio" and "get_ratio", the winning candidate
based on edit-distance lookup was the inaccessible member; the accessor
is "further away" in terms of edit distance.  I think it's useful to
the user to identify both, as this patch does.

> Would mentioning only the accessor be
> a better approach?

I think it's more helpful to the user to be explicit about what the
compiler is "thinking", and mention both.  Consider the case where the
accessor has a wildy different name to the misspelled member:

class foo {
public:
  int get_pertinent_data () { return m_val; }

private:
  int m_val;
};

int test (foo *f)
{
   return f->val;
}

The patch emits:

t.c: In function ‘int test(foo*)’:
t.c:11:14: error: ‘class foo’ has no member named ‘val’; did you mean
‘int foo::m_val’? (accessible via ‘int foo::get_pertinent_data()’)
11 |return f->val;
   |  ^~~
   |  get_pertinent_data()

which I think is clear and helpful.

> Also, to echo a comment made by someone else in a bug I don't
> remember, rather than phrasing the error in the form of
> a question ("did you mean x?") it might be better to either
> state what we know:
> 
>error: 'class foo' has no member named 'ratio'; the nearest
>  match is 'double foo::m_ratio' (accessible via 'double
>  foo::get_ratio() const')
> 
> or offer a suggestion:
> 
>error: 'class foo' has no member named 'ratio'; suggest
>  using 'double foo::get_ratio() const' instead

I think you're referring to PR 84890, though that bug was about this
kind of message:
  note: ‘INT_MAX’ is defined in header ‘’; did you forget to
‘#include ’?

PR 84890 combines several concerns:
(a) is the message too verbose? (initial comment)
(b) is the message potentially annoying to the user? (comment 5)
(c) is it better to phrase the message as a suggestion, rather than as
a question? (comment 8)

Taking these in turn:

(a) may apply to the missing include message, but I think the "did you
mean 'foo'" is short and clear

(b) both styles of message refer to the user as "you", which has a risk
of making things personal.  I think it's fine for the "did you mean"
case.  I think there's an argument that the "did you forget" could be
annoying - but that's not a concern for this patch.

(c) of the various wordings:
  (c.1) "did you mean 'foo'?" (as in the patch, and the status quo for
the rest of the C and C++ FE)
  (c.2) "suggest using 'foo' instead" doesn't seem grammatically
correct to me, in that it sounds like the user is being asked to
suggest something, rather than to change their cod

Re: [PATCH][i386] Split reductions (was: Re: [PATCH][RFC][i386] Change sminmax reduction patterns)

2018-10-09 Thread Uros Bizjak
On Tue, Oct 9, 2018 at 3:28 PM Richard Biener  wrote:
>
> On Mon, 8 Oct 2018, Richard Biener wrote:
>
> > On Fri, 5 Oct 2018, Uros Bizjak wrote:
> >
> > > On Thu, Oct 4, 2018 at 2:05 PM Richard Biener  wrote:
> > > >
> > > >
> > > > This tries to apply the same trick to sminmax reduction patterns
> > > > as for the reduc_plus_scal ones, namely reduce %zmm -> %ymm -> %xmm
> > > > first.  On a microbenchmark this improves performance on Zen
> > > > by ~30% for AVX2 and on Skylake-SP by ~10% for AVX512 (for AVX2
> > > > there's no measurable difference).
> > > >
> > > > I guess I'm mostly looking for feedback on the approach I took
> > > > in not rewriting ix86_expand_reduc but instead "recurse" on the
> > > > expanders as well as the need to define recursion stops for
> > > > SSE modes previously not covered.
> > > >
> > > > I'll throw this on a bootstrap & regtest on x86_64-unknown-linux-gnu
> > > > later.
> > > >
> > > > Any comments sofar?  Writing .md patterns is new for me ;)
> > >
> > > LGTM for the implementation.
> >
> > So this applies the method to all AVX2/AVX512 reduc_*_scal_* patterns
> > we have.  I've inspected the assembly and it looks as expected.
> >
> > Note I tried relying on the vectorizer to perform this, thus delete
> > the patterns.  Trying that for the reduc_plus_* ones reveals that
> > the final (SSE width) reduction step looks different and
> > unconditionally uses psrldq as the vectorizer expands the final
> > reduction step using whole-vector shifts.  Well, it actually
> > generates permutes like
> >
> >   vect_res_6.10_22 = VEC_PERM_EXPR <_21, { 0.0, 0.0, 0.0, 0.0 }, { 2, 3,
> > 4, 5 }>;
> >
> > but those end up using the vec_shr_ expander which puns
> > everything to V1TImode.  Removing the vec_shr_ expander
> > also doesn't get us the desired movhlps instruction for the
> > above (but a vshufps).  I'm not sure where to best fix that
> > (I think with good vec_perm expanders we shouldn't neeed the
> > vec_shr one - at least we'd keep the float/int domain), so I
> > kept all the reduc_* expanders we have now.  But I'll note
> > those we do not have (luckily all non-FP) use that
> > "inefficient"(?) instructions.  Like on Zen psrldq has a reciprocal
> > throughput of 1 while movhlps has one of 0.5, so using movhlps
> > would help loops with two reductions, on Skylake the opposite
> > seems to be the case...
> >
> > Boostrapped on x86_64-unknown-linux-gnu, testing in progress.
>
> Went fine after fixing ...
>
> > @@ -2585,9 +2556,14 @@ (define_expand "reduc__scal_
> >   (match_operand:VI_256 1 "register_operand"))]
> >"TARGET_AVX2"
> >  {
> > -  rtx tmp = gen_reg_rtx (mode);
> > -  ix86_expand_reduc (gen_3, tmp, operands[1]);
> > -  emit_insn (gen_vec_extract (operands[0], tmp,
> > +  rtx tmp = gen_reg_rtx (mode);
> > +  emit_insn (gen_vec_extract_hi_ (tmp, operands[1]));
> > +  rtx tmp2 = gen_reg_rtx (mode);
> > +  emit_insn (gen_3
> > +(tmp2, tmp, gen_lowpart (mode, operands[1])));
> > +  rtx tmp3 = gen_reg_rtx (mode);
>  ^^^
>
> > +  ix86_expand_reduc (gen_3, tmp3, tmp2);
> > +  emit_insn (gen_vec_extract (operands[0], tmp3,
> ^^^
>
> to use the proper mode (fixed patch re-attached below).
>
> OK?
>
> Richard.
>
> 2018-10-08  Richard Biener  
>
> * config/i386/sse.md (reduc_plus_scal_v8df, reduc_plus_scal_v4df,
> reduc_plus_scal_v2df, reduc_plus_scal_v16sf, reduc_plus_scal_v8sf,
> reduc_plus_scal_v4sf): Merge into pattern reducing to half width
> and recursing and pattern terminating the recursion on SSE
> vector width using ix86_expand_reduc.
> (reduc_sminmax_scal_): Split into part reducing to half
> width and recursing and SSE2 vector variant doing the final
> reduction with ix86_expand_reduc.
> (reduc_uminmax_scal_): Likewise for the AVX512 variants
> with terminating the recursion at AVX level, splitting that
> to SSE there.

OK.

Thanks,
Uros.

> diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
> index 692959b1666..9fc5819a863 100644
> --- a/gcc/config/i386/sse.md
> +++ b/gcc/config/i386/sse.md
> @@ -2457,98 +2457,65 @@
> (set_attr "prefix_rep" "1,*")
> (set_attr "mode" "V4SF")])
>
> -(define_expand "reduc_plus_scal_v8df"
> -  [(match_operand:DF 0 "register_operand")
> -   (match_operand:V8DF 1 "register_operand")]
> -  "TARGET_AVX512F"
> -{
> -  rtx tmp = gen_reg_rtx (V8DFmode);
> -  ix86_expand_reduc (gen_addv8df3, tmp, operands[1]);
> -  emit_insn (gen_vec_extractv8dfdf (operands[0], tmp, const0_rtx));
> -  DONE;
> -})
> +(define_mode_iterator REDUC_SSE_PLUS_MODE
> + [(V2DF "TARGET_SSE") (V4SF "TARGET_SSE")])
>
> -(define_expand "reduc_plus_scal_v4df"
> -  [(match_operand:DF 0 "register_operand")
> -   (match_operand:V4DF 1 "register_operand")]
> -  "TARGET_AVX"
> +(define_expand "reduc_plus_scal_"
> + [(plus:REDUC_SSE_PLUS_MODE
> +   (match_operand: 0 "register_operand")
> +   (match_operand:REDUC_SSE_PLUS_MODE 1 "register_operand"))]
> + ""
>  {
> -

[Ada] Spurious error message on visibiliy change in aspect expression

2018-10-09 Thread Pierre-Marie de Rodat
This patch removes an improper error message on a visibility change in
an aspect expression between the freeze point and the end of the
declaration list, when the expression involves a call to a instance of
Unchecked_Conversion and the enclosing package declaration has a package
body with multiple subprogram bodies.

The following must compile quietly:


package body Par.Rep is
   procedure Nothing is begin null; end;
   procedure Rien is begin null; end;
end;

with Par.Loc;
package Par.Rep is
   type Rec is record
  X, Y : Integer;
   end record
  with Volatile;

   Thing2 : Unsigned_32 := 15;
   Thing3 : Rec
with Volatile, Address => To_Address (Par.Loc.Flash_Base);
procedure Nothing;
end;

pragma Restrictions (No_Elaboration_Code);
with interfaces;  use interfaces;
pragma unreferenced (interfaces);
with Tp;   use Tp;
pragma unreferenced (Tp);
package Par is
end Par;

with Ada.Unchecked_Conversion;
with System;
with Interfaces; use Interfaces;
package Tp is
subtype system_address is unsigned_32;
   function to_address is new
  ada.unchecked_conversion (system_address, system.address);
   function To_32 is new
  ada.unchecked_conversion (System.Address, System_Address);
end;

with TP; use TP;
package Par.Loc is
FLASH_BASE: constant system_address := 16#0800_#;
end;

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-10-09  Ed Schonberg  

gcc/ada/

* sem_ch6.adb (Fully_Conformant_Expressions): Handle properly
the conformance check on an aspect expression that includes a
call to an instance of Unchecked_Conversion, or more generally a
call to an intrinsic operation.--- gcc/ada/sem_ch6.adb
+++ gcc/ada/sem_ch6.adb
@@ -8932,7 +8932,17 @@ package body Sem_Ch6 is
   or else
 (Chars (Entity (E1)) = Chars (Entity (E2))
   and then Ekind (Entity (E1)) = E_Loop_Parameter
-  and then Ekind (Entity (E2)) = E_Loop_Parameter);
+  and then Ekind (Entity (E2)) = E_Loop_Parameter)
+
+  --  A call to an instantiation of Unchecked_Conversion is
+  --  rewritten with the name of the generated function
+  --  created for the instance, and this must be special-cased.
+
+  or else
+ (Ekind (Entity (E1)) = E_Function
+   and then Is_Intrinsic_Subprogram (Entity (E1))
+   and then Is_Generic_Instance (Entity (E1))
+   and then Entity (E2) = Alias (Entity (E1)));
 
  elsif Nkind (E1) = N_Expanded_Name
and then Nkind (E2) = N_Expanded_Name



[Ada] Internal error on inlined renaming of subprogram instance

2018-10-09 Thread Pierre-Marie de Rodat
This fixes a recent regression introduced in the compiler for the
inlined renaming of a subprogram instantiated in a package body.  It was
wrongly clearing the Is_Public flag on the entity associated with the
body.

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-10-09  Eric Botcazou  

gcc/ada/

* sem_ch7.adb (Has_Referencer): Add comment for the
N_Freeze_Entity case.  Do not rely on
Has_Referencer_Of_Non_Subprograms to clear the Is_Public flag on
subprogram entities.

gcc/testsuite/

* gnat.dg/inline14.adb, gnat.dg/inline14_pkg.adb,
gnat.dg/inline14_pkg.ads: New testcase.--- gcc/ada/sem_ch7.adb
+++ gcc/ada/sem_ch7.adb
@@ -441,7 +441,13 @@ package body Sem_Ch7 is
  Discard : Boolean;
  pragma Unreferenced (Discard);
   begin
- --  Inspect the actions to find references to subprograms
+ --  Inspect the actions to find references to subprograms.
+ --  We assume that the actions do not contain other kinds
+ --  of references and, therefore, we do not stop the scan
+ --  or set Has_Referencer_Of_Non_Subprograms here. Doing
+ --  it would pessimize common cases for which the actions
+ --  contain the declaration of an init procedure, since
+ --  such a procedure is automatically marked inline.
 
  Discard :=
Has_Referencer (Actions (Decl),
@@ -470,7 +476,8 @@ package body Sem_Ch7 is
 and then not Is_Exported (Decl_Id)
 and then No (Interface_Name (Decl_Id))
 and then
-  (not Has_Referencer_Of_Non_Subprograms
+  ((Nkind (Decl) /= N_Subprogram_Declaration
+ and then not Has_Referencer_Of_Non_Subprograms)
 or else (Nkind (Decl) = N_Subprogram_Declaration
   and then not Subprogram_Table.Get (Decl_Id)))
   then

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/inline14.adb
@@ -0,0 +1,9 @@
+--  { dg-do compile }
+--  { dg-options "-O -gnatn" }
+
+with Inline14_Pkg; use Inline14_Pkg;
+
+procedure Inline14 is
+begin
+  Proc;
+end;

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/inline14_pkg.adb
@@ -0,0 +1,16 @@
+package body Inline14_Pkg is
+
+  I : Integer;
+
+  generic procedure Inner;
+
+  procedure Inner is
+  begin
+I := 0;
+  end;
+
+  procedure My_Inner is new Inner;
+
+  procedure Proc renames My_Inner;
+
+end Inline14_Pkg;

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/inline14_pkg.ads
@@ -0,0 +1,6 @@
+package Inline14_Pkg is
+
+  procedure Proc;
+  pragma Inline (Proc);
+
+end Inline14_Pkg;



[Ada] Fix spurious error on derived record passed as Out parameter

2018-10-09 Thread Pierre-Marie de Rodat
This fixlet gets rid of a spurious error issued in the specific case of
a call to a subprogram taking an Out parameter of a discriminated record
type without default discriminants, if the actual parameter is the
result of the conversion to the record type of a variable whose type is
derived from the record and has a representation clause.

The compiler was failing to initialize the temporary made around the
call because of the representation clause, but this is required for a
type with discriminants because discriminants may be read by the called
subprogram.

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-10-09  Eric Botcazou  

gcc/ada/

* exp_ch6.adb (Add_Call_By_Copy_Code): Initialize the temporary
made for an Out parameter if the formal type has discriminants.

gcc/testsuite/

* gnat.dg/derived_type5.adb, gnat.dg/derived_type5_pkg.ads: New
testcase.--- gcc/ada/exp_ch6.adb
+++ gcc/ada/exp_ch6.adb
@@ -1321,8 +1321,14 @@ package body Exp_Ch6 is
  --  bounds of the actual and build an uninitialized temporary of the
  --  right size.
 
+ --  If the formal is an out parameter with discriminants, the
+ --  discriminants must be captured even if the rest of the object
+ --  is in principle uninitialized, because the discriminants may
+ --  be read by the called subprogram.
+
  if Ekind (Formal) = E_In_Out_Parameter
or else (Is_Array_Type (F_Typ) and then not Is_Constrained (F_Typ))
+   or else Has_Discriminants (F_Typ)
  then
 if Nkind (Actual) = N_Type_Conversion then
if Conversion_OK (Actual) then

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/derived_type5.adb
@@ -0,0 +1,10 @@
+--  { dg-do compile }
+
+with Derived_Type5_Pkg; use Derived_Type5_Pkg;
+
+procedure Derived_Type5 is
+  D : Derived;
+begin
+  Proc1 (Rec (D));
+  Proc2 (Rec (D));
+end;

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/derived_type5_pkg.ads
@@ -0,0 +1,27 @@
+package Derived_Type5_Pkg is
+
+   type T_Unsigned8  is new Natural range 0 .. (2 ** 8 - 1);
+
+   type Rec (Discriminant : T_Unsigned8) is record
+  Fixed_Field : T_Unsigned8;
+  case Discriminant is
+ when 0 =>
+Optional_Field : T_unsigned8;
+ when others =>
+null;
+  end case;
+   end record;
+
+   type Derived is new Rec (0);
+
+   for Derived use record
+  Fixed_Fieldat 0 range 0  .. 7;
+  Discriminant   at 0 range 8  .. 15;
+  Optional_Field at 0 range 16 .. 23;
+   end record;
+
+   procedure Proc1 (R : in out Rec);
+
+   procedure Proc2 (R : out Rec);
+
+end Derived_Type5_Pkg;



[Ada] Fix strange warning when using Ada.Iterator_Interface

2018-10-09 Thread Pierre-Marie de Rodat
The back-end was recently changed to issue more -Wuninitialized warnings
on Out parameters and this has caught a case related to
Ada.Iterator_Interface.: This patchlet simply kills this uninteresting
warning.

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-10-09  Eric Botcazou  

gcc/ada/

* exp_disp.adb (Make_Disp_Asynchronous_Select_Spec): Set
Warnings_Off on the B out parameter.

gcc/testsuite/

* gnat.dg/warn17.adb: New testcase.--- gcc/ada/exp_disp.adb
+++ gcc/ada/exp_disp.adb
@@ -2487,9 +2487,10 @@ package body Exp_Disp is
  (Typ : Entity_Id) return Node_Id
is
   Loc: constant Source_Ptr := Sloc (Typ);
-  Def_Id : constant Node_Id:=
+  Def_Id : constant Entity_Id :=
  Make_Defining_Identifier (Loc,
Name_uDisp_Asynchronous_Select);
+  B_Id   : constant Entity_Id  := Make_Defining_Identifier (Loc, Name_uB);
   Params : constant List_Id:= New_List;
 
begin
@@ -2501,6 +2502,9 @@ package body Exp_Disp is
   --  B : out Dummy_Communication_Block;  --  Communication block dummy
   --  F : out Boolean;--  Status flag
 
+  --  The B parameter may be left uninitialized
+  Set_Warnings_Off (B_Id);
+
   Append_List_To (Params, New_List (
 
 Make_Parameter_Specification (Loc,
@@ -2518,7 +2522,7 @@ package body Exp_Disp is
   Parameter_Type  => New_Occurrence_Of (RTE (RE_Address), Loc)),
 
 Make_Parameter_Specification (Loc,
-  Defining_Identifier => Make_Defining_Identifier (Loc, Name_uB),
+  Defining_Identifier => B_Id,
   Parameter_Type  =>
 New_Occurrence_Of (RTE (RE_Dummy_Communication_Block), Loc),
   Out_Present => True),

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/warn17.adb
@@ -0,0 +1,22 @@
+--  { dg-do compile }
+--  { dg-options "-Wall" }
+
+with Ada.Iterator_Interfaces;
+
+procedure Warn17 is
+
+   type Cursor is null record;
+
+   function Has_Element (Position : Cursor) return Boolean;
+
+   function Has_Element (Position : Cursor) return Boolean is (True);
+
+   package My_Iterator is
+ new Ada.Iterator_Interfaces (Cursor, Has_Element);
+
+   type Iterator is abstract new My_Iterator.Forward_Iterator with null record;
+
+   pragma Unreferenced (Iterator);
+begin
+   null;
+end Warn17;



[Ada] Ignore pragmas Compile_Time_Error/Warning in GNATprove mode

2018-10-09 Thread Pierre-Marie de Rodat
GNATprove does not have sometimes the precise information of the
compiler about size of types and objects, so that it cannot evaluate the
expressions in pragma Compile_Time_Error/Warning the same way the
compiler does.  Thus, these pragmas should be ignored in GNATprove mode,
as it can neither verify them nor assume them (if the expression cannot
be evaluated at compile time, then the semantics for GNAT is to ignore
them).

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-10-09  Yannick Moy  

gcc/ada/

* sem_prag.adb (Process_Compile_Time_Warning_Or_Error): Rewrite
pragmas as null statements in GNATprove mode.--- gcc/ada/sem_prag.adb
+++ gcc/ada/sem_prag.adb
@@ -7570,6 +7570,17 @@ package body Sem_Prag is
   --  Start of processing for Process_Compile_Time_Warning_Or_Error
 
   begin
+ --  In GNATprove mode, pragmas Compile_Time_Error and
+ --  Compile_Time_Warning are ignored, as the analyzer may not have the
+ --  same information as the compiler (in particular regarding size of
+ --  objects decided in gigi) so it makes no sense to issue an error or
+ --  warning in GNATprove.
+
+ if GNATprove_Mode then
+Rewrite (N, Make_Null_Statement (Loc));
+return;
+ end if;
+
  Check_Arg_Count (2);
  Check_No_Identifiers;
  Check_Arg_Is_OK_Static_Expression (Arg2, Standard_String);



[Ada] Fix spurious -Wuninitialized warnings for small records

2018-10-09 Thread Pierre-Marie de Rodat
This change is aimed at getting rid of spurious -Wuninitialized warnings
issued for small records passed by copy and containing default values
for some of their components.

The source of the problem is that the _Init parameter of the
initialization routine is declared as an in/out parameter, so the
uninitialized object is passed by copy to it and this can be flagged by
-Wuninitialized.

That's why the mode of the parameter is changed to out, except for the
cases where information really needs to be passed in: unconstrained
array types, protected and task types.

For the following record type Rec!

 type Rec is record
B : Boolean := True;
  end record;

the initialization routine must now be:

  procedure r__recIP (_init : out r__rec1) is
  begin
 _init.b := true;
 return;
  end r__recIP;

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-10-09  Eric Botcazou  

gcc/ada/

* exp_ch3.adb (Is_Null_Statement_List): New predicate.
(Build_Array_Init_Proc): Use it to find out whether the
initialization procedure Is_Null_Init_Proc; if so, set
Warnings_Off on the parameter.
(Build_Init_Procedure): Likewise.
(Init_Formals): Use an in/out first parameter only for
unconstrained arrays and for records either containing or built
for proteced types or task types; use an out parameter in all
the other cases.
* fe.h (Is_Init_Proc): Declare.
* gcc-interface/decl.c (type_requires_init_of_formal): Do not
return true for a discriminant in an unchecked union.
(gnat_to_gnu_param): Do not create a PARM_DECL for the Out
parameter of an initialization procedure.--- gcc/ada/exp_ch3.adb
+++ gcc/ada/exp_ch3.adb
@@ -202,6 +202,11 @@ package body Exp_Ch3 is
--  Check if E is defined in the RTL (in a child of Ada or System). Used
--  to avoid to bring in the overhead of _Input, _Output for tagged types.
 
+   function Is_Null_Statement_List (Stmts : List_Id) return Boolean;
+   --  Returns true if Stmts is made of null statements only, possibly wrapped
+   --  in a case statement, recursively. This latter pattern may occur for the
+   --  initialization procedure of an unchecked union.
+
function Is_User_Defined_Equality (Prim : Node_Id) return Boolean;
--  Returns true if Prim is a user defined equality function
 
@@ -529,6 +534,7 @@ package body Exp_Ch3 is
   Has_Default_Init : Boolean;
   Index_List   : List_Id;
   Loc  : Source_Ptr;
+  Parameters   : List_Id;
   Proc_Id  : Entity_Id;
 
   function Init_Component return List_Id;
@@ -722,13 +728,14 @@ package body Exp_Ch3 is
  end if;
 
  Body_Stmts := Init_One_Dimension (1);
+ Parameters := Init_Formals (A_Type);
 
  Discard_Node (
Make_Subprogram_Body (Loc,
  Specification =>
Make_Procedure_Specification (Loc,
  Defining_Unit_Name => Proc_Id,
- Parameter_Specifications => Init_Formals (A_Type)),
+ Parameter_Specifications => Parameters),
  Declarations => New_List,
  Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc,
@@ -753,18 +760,14 @@ package body Exp_Ch3 is
  --  where we have to generate a null procedure in case it is called
  --  by a client with Initialize_Scalars set). Such procedures have
  --  to be generated, but do not have to be called, so we mark them
- --  as null to suppress the call.
+ --  as null to suppress the call. Kill also warnings for the _Init
+ --  out parameter, which is left entirely uninitialized.
 
  Set_Init_Proc (A_Type, Proc_Id);
 
- if List_Length (Body_Stmts) = 1
-
-   --  We must skip SCIL nodes because they may have been added to this
-   --  list by Insert_Actions.
-
-   and then Nkind (First_Non_SCIL_Node (Body_Stmts)) = N_Null_Statement
- then
+ if Is_Null_Statement_List (Body_Stmts) then
 Set_Is_Null_Init_Proc (Proc_Id);
+Set_Warnings_Off (Defining_Identifier (First (Parameters)));
 
  else
 --  Try to build a static aggregate to statically initialize
@@ -2803,18 +2806,14 @@ package body Exp_Ch3 is
  --  where we have to generate a null procedure in case it is called
  --  by a client with Initialize_Scalars set). Such procedures have
  --  to be generated, but do not have to be called, so we mark them
- --  as null to suppress the call.
+ --  as null to suppress the call. Kill also warnings for the _Init
+ --  out parameter, which is left entirely uninitialized.
 
  Set_Init_Proc (Rec_Type, Proc_Id);
 
- if List_Length (Body_Stmts) = 1
-
-   --  We must skip SCIL nodes because they may have been added to this
-   --  list by I

Re: [C++ Patch] PR 84423 ("[6/7/8/9 Regression] [concepts] ICE with invalid using declaration")

2018-10-09 Thread Jason Merrill
On Sat, Sep 29, 2018 at 3:27 PM Paolo Carlini  wrote:
> Hi again,
>
> On 9/28/18 9:15 PM, Paolo Carlini wrote:
> > Thanks. About the location, you are certainly right, but doesn't seem
> > trivial. Something we can do *now* is using
> > declspecs->locations[ds_typedef] and declspecs->locations[ds_alias],
> > but that gives us the location of the keyword 'typedef' and 'using',
> > respectively, whereas I think that we would like to have the location
> > of 'auto' itself. I could look into that as a follow-up piece work
>
> In fact, completing the work turned out to be easy: ensure that
> cp_parser_alias_declaration saves the location of the defining-type-id
> too and then consistently use locations[ds_type_spec] in the error
> messages. Tested x86_64-linux. Still Ok? ;)

Hmm, I think you need to look past any cv-qualifiers at the beginning
of the type-id.

Jason


libgo patch committed: Skip testSetPanicOnFault when using LLVM

2018-10-09 Thread Ian Lance Taylor
This patch by Cherry Zhang skips the testSetPanicOnFault tests when
using gollvm.  LLVM doesn't support non-call exceptions. This test was
passing more or less by luck: if the faulting instruction is between
two calls with the same landing pad (in instruction layout order, not
the program's logic order), it generates a merged PC range that covers
the faulting instruction. If the instruction layout order changes, or
it uses two different (but may be degenerate) landing pads, this
doesn't work.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 264932)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-a9da4d34a2f878a5058f7e7d2beef52aa62471a1
+e32e9aaee598eeb43f9616cf6ca1d11acaa9d167
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/runtime/runtime_test.go
===
--- libgo/go/runtime/runtime_test.go(revision 264813)
+++ libgo/go/runtime/runtime_test.go(working copy)
@@ -166,6 +166,9 @@ func TestSetPanicOnFault(t *testing.T) {
 }
 
 func testSetPanicOnFault(t *testing.T, addr uintptr, nfault *int) {
+   if strings.Contains(Version(), "llvm") {
+   t.Skip("LLVM doesn't support non-call exception")
+   }
if GOOS == "nacl" {
t.Skip("nacl doesn't seem to fault on high addresses")
}


Re: [PATCHv2] Handle not explicitly zero terminated strings in merge sections

2018-10-09 Thread Eric Botcazou
> Which version exactly (pkg list entire) of Solaris 11 are you running?
> I'm using gas 2.31 and /bin/ld on Solaris 11.4 resp. 11.5 Beta, where
> Bernd's patch in PR bootstrap/87551 fixed the remaining regressions.

Solaris 11.3 with Gas 2.30.

-- 
Eric Botcazou


Re: [patch] Fix PR tree-optimization/86659

2018-10-09 Thread Eric Botcazou
> 2018-09-28  Eric Botcazou  
> 
>   PR tree-optimization/86659
>   * gimple-match.h (struct gimple_match_op): Add reverse field.

Jonathan privately remarked that the new member should probably be initialized 
in the constructors (thanks!).  Done thusly, applied on mainline as obvious.

PR tree-optimization/86659
* gimple-match.h (gimple_match_op constructors): Initialize reverse.

-- 
Eric BotcazouIndex: gimple-match.h
===
--- gimple-match.h	(revision 264942)
+++ gimple-match.h	(working copy)
@@ -131,7 +131,8 @@ struct gimple_match_op
 
 inline
 gimple_match_op::gimple_match_op ()
-  : cond (gimple_match_cond::UNCOND), type (NULL_TREE), num_ops (0)
+  : cond (gimple_match_cond::UNCOND), type (NULL_TREE), reverse (false),
+num_ops (0)
 {
 }
 
@@ -142,7 +143,8 @@ inline
 gimple_match_op::gimple_match_op (const gimple_match_cond &cond_in,
   code_helper code_in, tree type_in,
   unsigned int num_ops_in)
-  : cond (cond_in), code (code_in), type (type_in), num_ops (num_ops_in)
+  : cond (cond_in), code (code_in), type (type_in), reverse (false),
+num_ops (num_ops_in)
 {
 }
 
@@ -152,7 +154,8 @@ inline
 gimple_match_op::gimple_match_op (const gimple_match_cond &cond_in,
   code_helper code_in, tree type_in,
   tree op0)
-  : cond (cond_in), code (code_in), type (type_in), num_ops (1)
+  : cond (cond_in), code (code_in), type (type_in), reverse (false),
+num_ops (1)
 {
   ops[0] = op0;
 }
@@ -161,7 +164,8 @@ inline
 gimple_match_op::gimple_match_op (const gimple_match_cond &cond_in,
   code_helper code_in, tree type_in,
   tree op0, tree op1)
-  : cond (cond_in), code (code_in), type (type_in), num_ops (2)
+  : cond (cond_in), code (code_in), type (type_in), reverse (false), 
+num_ops (2)
 {
   ops[0] = op0;
   ops[1] = op1;
@@ -171,7 +175,8 @@ inline
 gimple_match_op::gimple_match_op (const gimple_match_cond &cond_in,
   code_helper code_in, tree type_in,
   tree op0, tree op1, tree op2)
-  : cond (cond_in), code (code_in), type (type_in), num_ops (3)
+  : cond (cond_in), code (code_in), type (type_in), reverse (false),
+num_ops (3)
 {
   ops[0] = op0;
   ops[1] = op1;
@@ -182,7 +187,8 @@ inline
 gimple_match_op::gimple_match_op (const gimple_match_cond &cond_in,
   code_helper code_in, tree type_in,
   tree op0, tree op1, tree op2, tree op3)
-  : cond (cond_in), code (code_in), type (type_in), num_ops (4)
+  : cond (cond_in), code (code_in), type (type_in), reverse (false),
+num_ops (4)
 {
   ops[0] = op0;
   ops[1] = op1;
@@ -195,7 +201,8 @@ gimple_match_op::gimple_match_op (const
   code_helper code_in, tree type_in,
   tree op0, tree op1, tree op2, tree op3,
   tree op4)
-  : cond (cond_in), code (code_in), type (type_in), num_ops (5)
+  : cond (cond_in), code (code_in), type (type_in), reverse (false),
+num_ops (5)
 {
   ops[0] = op0;
   ops[1] = op1;


[PATCH] C++: simplify output from suggest_alternatives_for

2018-10-09 Thread David Malcolm
In the C++ FE, after emitting various errors about unrecognized names,
the parser can call
  suggest_alternatives_for
and/or
  suggest_alternative_in_explicit_scope.
These can issue zero or more suggestions for the unrecognized name,
or various other "note" diagnostics suggesting how to fix the problem.

For example, currently g++ emits:

t.cc:12:3: error: 'gtk_widget_showall' was not declared in this scope
12 |   gtk_widget_showall (w);
   |   ^~
t.cc:12:3: note: suggested alternative: 'gtk_widget_show_all'
12 |   gtk_widget_showall (w);
   |   ^~
   |   gtk_widget_show_all

This patch consolidates the common case when there is a single
candidate, so that the error can issue a fix-it hint directly.

This simplifies the above to:

t.cc:12:3: error: 'gtk_widget_showall' was not declared in this scope;
 did you mean 'gtk_widget_show_all'?
12 |   gtk_widget_showall (w);
   |   ^~
   |   gtk_widget_show_all

omitting the second "note" diagnostic.

Doing so requires changing the above "suggest_" functions so that
rather than being called after "error" and emitting a note directly,
they are called before the "error", and return a name_hint, which
can contain a suggestion and/or a deferred diagnostic.  The "single
candidate" case is handled via a suggestion, and the "multiple
candidates" case via a new subclass of deferred_diagnostic.

There was some complication due to the fact that we don't always have
enough location information to issue a fix-it hint.  Specifically,
for the case in qualified_name_lookup_error, the location is that of
the name, but the location of the qualifier prefix isn't reliably
available.  For some hints, e.g. spell-corrections, the replacement
is of the name, and for others, e.g. parent namespaces, it's for the
qualified name.  The patch addresses this by splitting this case out
into a new "suggest_alternatives_in_other_namespaces" function, for
which fix-it hints aren't issued.

Another complication is that of emitting a note when
  --param cxx-max-namespaces-for-diagnostic-help
is reached.  The patch emulates the existing behavior by emitting
the note from a deferred_diagnostic.  This potentially needs to
co-exist with another deferred_diagnostic, so it works as a decorator
around any other such deferred_diagnostic.  Doing so requires slightly
extending class name_hint.

On adding test coverage for the various cases, I discovered that
after emitting a "FOO is not a namespace-name" error, we also emit
a "expected namespace-name before" error.  The patch removes this
second error for the case where it's redundant, simplifying this case
from e.g.:

spellcheck-ns.C:10:24: error: 'inner_ms' is not a namespace-name
10 | using namespace outer::inner_ms;
   |^~~~
spellcheck-ns.C:10:24: note: suggested alternative: 'inner_ns'
10 | using namespace outer::inner_ms;
   |^~~~
   |inner_ns
spellcheck-ns.C:10:32: error: expected namespace-name before ';' token
10 | using namespace outer::inner_ms;
   |^

to:

spellcheck-ns.C:10:24: error: 'inner_ms' is not a namespace-name;
 did you mean 'inner_ns'?
10 | using namespace outer::inner_ms;
   |^~~~
   |inner_ns

Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu
(on top of
  https://gcc.gnu.org/ml/gcc-patches/2018-09/msg01272.html
  "v2: C++: suggestions for misspelled private members (PR c++/84993)")

OK for trunk?

gcc/c-family/ChangeLog:
* name-hint.h (class name_hint): Add copy constructor and copy
assignment operator.
(name_hint::operator bool): Also return true if m_deferred is
non-NULL.
(name_hint::take_deferred): New member function.

gcc/c/ChangeLog:
* c-decl.c (implicit_decl_warning): Update "is there a suggestion"
logic for change to name_hint::operator bool.
(undeclared_variable): Likewise.
* c-parser.c (c_parser_declaration_or_fndef): Likewise.
(c_parser_parameter_declaration): Likewise.

gcc/cp/ChangeLog:
* cp-name-hint.h: New file.
* cp-tree.h (expr_to_string): New decl.
(suggest_alternatives_for): Move to cp-name-hint.h, changing
return type from bool to name_hint.
(suggest_alternative_in_explicit_scope): Likewise.
* error.c: Define INCLUDE_UNIQUE_PTR.  Include "cp-name-hint.h".
(expr_to_string): Make non-static.
(qualified_name_lookup_error): For the non-"::" case, take
responsibity for issuing any suggestion from
suggest_alternative_in_explicit_scope, as it changes from
returning a bool to returning a name_hint.  Replace fallback call
to suggest_alternatives_for to a call to
suggest_alternatives_in_other_namespaces, capturing the fact that
we don't have enough location information to issue a fix-it hint
for this case.  U

Re: [C++ Patch] PR 84423 ("[6/7/8/9 Regression] [concepts] ICE with invalid using declaration")

2018-10-09 Thread Paolo Carlini

Hi,

On 09/10/18 17:17, Jason Merrill wrote:

On Sat, Sep 29, 2018 at 3:27 PM Paolo Carlini  wrote:

Hi again,

On 9/28/18 9:15 PM, Paolo Carlini wrote:

Thanks. About the location, you are certainly right, but doesn't seem
trivial. Something we can do *now* is using
declspecs->locations[ds_typedef] and declspecs->locations[ds_alias],
but that gives us the location of the keyword 'typedef' and 'using',
respectively, whereas I think that we would like to have the location
of 'auto' itself. I could look into that as a follow-up piece work

In fact, completing the work turned out to be easy: ensure that
cp_parser_alias_declaration saves the location of the defining-type-id
too and then consistently use locations[ds_type_spec] in the error
messages. Tested x86_64-linux. Still Ok? ;)

Hmm, I think you need to look past any cv-qualifiers at the beginning
of the type-id.


Ah, good point. The information is readily available in 
cp_parser_type_id thus we can simply return it to 
cp_parser_alias_declaration. I guess an alternate approach would be 
adding a pointer to the whole cp_decl_specifier_seq parameter to 
cp_parser_type_id (and cp_parser_type_id_1, etc), but that seems over 
killing to me.


Thanks! Paolo.

/

Index: cp/decl.c
===
--- cp/decl.c   (revision 264985)
+++ cp/decl.c   (working copy)
@@ -11879,6 +11879,7 @@ grokdeclarator (const cp_declarator *declarator,
   /* If this is declaring a typedef name, return a TYPE_DECL.  */
   if (typedef_p && decl_context != TYPENAME)
 {
+  bool alias_p = decl_spec_seq_has_spec_p (declspecs, ds_alias);
   tree decl;
 
   /* This declaration:
@@ -11901,7 +11902,12 @@ grokdeclarator (const cp_declarator *declarator,
 
   if (type_uses_auto (type))
{
- error ("typedef declared %");
+ if (alias_p)
+   error_at (declspecs->locations[ds_type_spec],
+ "% not allowed in alias declaration");
+ else
+   error_at (declspecs->locations[ds_type_spec],
+ "typedef declared %");
  type = error_mark_node;
}
 
@@ -11961,7 +11967,7 @@ grokdeclarator (const cp_declarator *declarator,
  inlinep, friendp, raises != NULL_TREE,
  declspecs->locations);
 
-  if (decl_spec_seq_has_spec_p (declspecs, ds_alias))
+  if (alias_p)
/* Acknowledge that this was written:
 `using analias = atype;'.  */
TYPE_DECL_ALIAS_P (decl) = 1;
Index: cp/parser.c
===
--- cp/parser.c (revision 264985)
+++ cp/parser.c (working copy)
@@ -2216,12 +2216,12 @@ static tree cp_parser_late_return_type_opt
 static tree cp_parser_declarator_id
   (cp_parser *, bool);
 static tree cp_parser_type_id
-  (cp_parser *);
+  (cp_parser *, location_t * = NULL);
 static tree cp_parser_template_type_arg
   (cp_parser *);
 static tree cp_parser_trailing_type_id (cp_parser *);
 static tree cp_parser_type_id_1
-  (cp_parser *, bool, bool);
+  (cp_parser *, bool, bool, location_t *);
 static void cp_parser_type_specifier_seq
   (cp_parser *, bool, bool, cp_decl_specifier_seq *);
 static tree cp_parser_parameter_declaration_clause
@@ -19034,7 +19034,7 @@ static tree
 cp_parser_alias_declaration (cp_parser* parser)
 {
   tree id, type, decl, pushed_scope = NULL_TREE, attributes;
-  location_t id_location;
+  location_t id_location, type_location;
   cp_declarator *declarator;
   cp_decl_specifier_seq decl_specs;
   bool member_p;
@@ -19086,7 +19086,7 @@ cp_parser_alias_declaration (cp_parser* parser)
G_("types may not be defined in alias template declarations");
 }
 
-  type = cp_parser_type_id (parser);
+  type = cp_parser_type_id (parser, &type_location);
 
   /* Restore the error message if need be.  */
   if (parser->num_template_parameter_lists)
@@ -19120,6 +19120,7 @@ cp_parser_alias_declaration (cp_parser* parser)
   set_and_check_decl_spec_loc (&decl_specs,
   ds_alias,
   using_token);
+  decl_specs.locations[ds_type_spec] = type_location;
 
   if (parser->num_template_parameter_lists
   && !cp_parser_check_template_parameters (parser,
@@ -21110,7 +2,7 @@ cp_parser_declarator_id (cp_parser* parser, bool o
 
 static tree
 cp_parser_type_id_1 (cp_parser* parser, bool is_template_arg,
-bool is_trailing_return)
+bool is_trailing_return, location_t * type_location)
 {
   cp_decl_specifier_seq type_specifier_seq;
   cp_declarator *abstract_declarator;
@@ -21119,6 +21120,9 @@ cp_parser_type_id_1 (cp_parser* parser, bool is_te
   cp_parser_type_specifier_seq (parser, /*is_declaration=*/false,
is_trailing_return,
&type_specifier_seq);
+  if (type_location)
+*type_location = type_specifier_seq.locations[ds_type_spec]

Re: [C++ Patch] PR 84423 ("[6/7/8/9 Regression] [concepts] ICE with invalid using declaration")

2018-10-09 Thread Jason Merrill
OK.
On Tue, Oct 9, 2018 at 1:49 PM Paolo Carlini  wrote:
>
> Hi,
>
> On 09/10/18 17:17, Jason Merrill wrote:
> > On Sat, Sep 29, 2018 at 3:27 PM Paolo Carlini  
> > wrote:
> >> Hi again,
> >>
> >> On 9/28/18 9:15 PM, Paolo Carlini wrote:
> >>> Thanks. About the location, you are certainly right, but doesn't seem
> >>> trivial. Something we can do *now* is using
> >>> declspecs->locations[ds_typedef] and declspecs->locations[ds_alias],
> >>> but that gives us the location of the keyword 'typedef' and 'using',
> >>> respectively, whereas I think that we would like to have the location
> >>> of 'auto' itself. I could look into that as a follow-up piece work
> >> In fact, completing the work turned out to be easy: ensure that
> >> cp_parser_alias_declaration saves the location of the defining-type-id
> >> too and then consistently use locations[ds_type_spec] in the error
> >> messages. Tested x86_64-linux. Still Ok? ;)
> > Hmm, I think you need to look past any cv-qualifiers at the beginning
> > of the type-id.
>
> Ah, good point. The information is readily available in
> cp_parser_type_id thus we can simply return it to
> cp_parser_alias_declaration. I guess an alternate approach would be
> adding a pointer to the whole cp_decl_specifier_seq parameter to
> cp_parser_type_id (and cp_parser_type_id_1, etc), but that seems over
> killing to me.
>
> Thanks! Paolo.
>
> /
>


Re: [PATCH] PR libgcc/60790: Avoid IFUNC resolver access to uninitialized data

2018-10-09 Thread Florian Weimer
* Jeff Law:

> On 03/29/2018 08:00 AM, Florian Weimer wrote:
>> This patch performs lazy initialization of the relevant CPUID feature
>> register value.  It will needlessly invoke the CPUID determination code
>> on architectures which lack CPUID support or support for the feature
>> register, but I think it's not worth to avoid the complexity for that.
>> 
>> I verified manually that the CMPXCHG16B implementation is still selected
>> for a 128-bit load after the change.  I don't know how to write an
>> automated test for that.
>> 
>> Thanks,
>> Florian
>> 
>> pr60790.patch
>> 
>> 
>> Index: libatomic/ChangeLog
>> ===
>> --- libatomic/ChangeLog  (revision 258952)
>> +++ libatomic/ChangeLog  (working copy)
>> @@ -1,3 +1,18 @@
>> +2018-03-29  Florian Weimer  
>> +
>> +PR libgcc/60790
>> +x86: Do not assume ELF constructors run before IFUNC resolvers.
>> +* config/x86/host-config.h (libat_feat1_ecx, libat_feat1_edx):
>> +Remove declarations.
>> +(__libat_feat1, __libat_feat1_init): Declare.
>> +(FEAT1_REGISTER): Define.
>> +(load_feat1): New function.
>> +(IFUNC_COND_1): Adjust.
>> +* config/x86/init.c (libat_feat1_ecx, libat_feat1_edx)
>> +(init_cpuid): Remove definitions.
>> +(__libat_feat1): New variable.
>> +(__libat_feat1_init): New function.
> OK.

Here is the backport to gcc-8-branch.

libatomic/ChangeLog

PR libgcc/60790
x86: Do not assume ELF constructors run before IFUNC resolvers.
* config/x86/host-config.h (libat_feat1_ecx, libat_feat1_edx):
Remove declarations.
(__libat_feat1, __libat_feat1_init): Declare.
(FEAT1_REGISTER): Define.
(load_feat1): New function.
(IFUNC_COND_1): Adjust.
* config/x86/init.c (libat_feat1_ecx, libat_feat1_edx)
(init_cpuid): Remove definitions.
(__libat_feat1): New variable.
(__libat_feat1_init): New function.

Index: libatomic/config/x86/host-config.h
===
--- libatomic/config/x86/host-config.h  (revision 264990)
+++ libatomic/config/x86/host-config.h  (working copy)
@@ -25,13 +25,39 @@
 #if HAVE_IFUNC
 #include 
 
-extern unsigned int libat_feat1_ecx HIDDEN;
-extern unsigned int libat_feat1_edx HIDDEN;
+#ifdef __x86_64__
+# define FEAT1_REGISTER ecx
+#else
+# define FEAT1_REGISTER edx
+#endif
 
+/* Value of the CPUID feature register FEAT1_REGISTER for the cmpxchg
+   bit for IFUNC_COND1 below.  */
+extern unsigned int __libat_feat1 HIDDEN;
+
+/* Initialize libat_feat1 and return its value.  */
+unsigned int __libat_feat1_init (void) HIDDEN;
+
+/* Return the value of the relevant feature register for the relevant
+   cmpxchg bit, or 0 if there is no CPUID support.  */
+static inline unsigned int
+__attribute__ ((const))
+load_feat1 (void)
+{
+  /* See the store in __libat_feat1_init.  */
+  unsigned int feat1 = __atomic_load_n (&__libat_feat1, __ATOMIC_RELAXED);
+  if (feat1 == 0)
+/* Assume that initialization has not happened yet.  This may get
+   called repeatedly if the CPU does not have any feature bits at
+   all.  */
+feat1 = __libat_feat1_init ();
+  return feat1;
+}
+
 #ifdef __x86_64__
-# define IFUNC_COND_1  (libat_feat1_ecx & bit_CMPXCHG16B)
+# define IFUNC_COND_1  (load_feat1 () & bit_CMPXCHG16B)
 #else
-# define IFUNC_COND_1  (libat_feat1_edx & bit_CMPXCHG8B)
+# define IFUNC_COND_1  (load_feat1 () & bit_CMPXCHG8B)
 #endif
 
 #ifdef __x86_64__
Index: libatomic/config/x86/init.c
===
--- libatomic/config/x86/init.c (revision 264990)
+++ libatomic/config/x86/init.c (working copy)
@@ -26,13 +26,17 @@
 
 #if HAVE_IFUNC
 
-unsigned int libat_feat1_ecx, libat_feat1_edx;
+unsigned int __libat_feat1;
 
-static void __attribute__((constructor))
-init_cpuid (void)
+unsigned int
+__libat_feat1_init (void)
 {
-  unsigned int eax, ebx;
-  __get_cpuid (1, &eax, &ebx, &libat_feat1_ecx, &libat_feat1_edx);
+  unsigned int eax, ebx, ecx, edx;
+  FEAT1_REGISTER = 0;
+  __get_cpuid (1, &eax, &ebx, &ecx, &edx);
+  /* See the load in load_feat1.  */
+  __atomic_store_n (&__libat_feat1, FEAT1_REGISTER, __ATOMIC_RELAXED);
+  return FEAT1_REGISTER;
 }
 
 #endif /* HAVE_IFUNC */
Index: .
===
--- .   (revision 264990)
+++ .   (working copy)

Property changes on: .
___
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /trunk:r260603


Re: [PATCH] Remove dead functions and fix VMS target by moving back some functions.

2018-10-09 Thread Martin Jambor
On Tue, Oct 09 2018, Martin Liška wrote:
> Hi.
>
> Utilizing rtags' --find-dead-functions I'm suggesting a removal of part
> of the functions reported with the script. I built all cross compilers
> defined in contrib/config-list.mk and I fixed VMS targets that I broke
> in previous removal.
>
> If the folks are happy with the removal, I can probably continue with that
> at some point in stage3 or so.
>
> Ready for trunk?
> Thanks,
> Martin
> From f69d866da42a46783ab57181692583d2ecf30c49 Mon Sep 17 00:00:00 2001
> From: marxin 
> Date: Fri, 5 Oct 2018 16:59:07 +0200
> Subject: [PATCH] Remove dead functions and fix VMS target by moving back some
>  functions.
>
> gcc/ChangeLog:
>
> 2018-10-09  Martin Liska  
>
>   * attribs.c (register_attribute): Remove unused functions.
>   * cfganal.c (control_dependences::clear_control_dependence_bitmap): 
> Likewise.
>   (bitmap_union_of_succs): Likewise.
>   * cfganal.h (bitmap_union_of_succs): Likewise.
>   * cfgloop.c (loop_exits_to_bb_p): Likewise.
>   * cfgloop.h (loop_exits_to_bb_p): Likewise.
>   * cgraph.h (compute_call_stmt_bb_frequency): Likewise.
>   * cgraphbuild.c (compute_call_stmt_bb_frequency): Likewise.
>   * cselib.c (cselib_dummy_expand_value_rtx_cb): Likewise.
>   * cselib.h (cselib_dummy_expand_value_rtx_cb): Likewise.
>   * df-core.c (df_reg_defined): Likewise.
>   (df_reg_used): Likewise.
>   * df-scan.c (df_hard_reg_used_count): Likewise.
>   * df.h (df_reg_defined): Likewise.
>   (df_reg_used): Likewise.
>   (df_hard_reg_used_count): Likewise.
>   * dojump.c (init_pending_stack_adjust): Likewise.
>   * dojump.h (init_pending_stack_adjust): Likewise.
>   * dwarf2out.c (add_AT_vms_delta): Move function back after
>   removal.
>   (dwarf2out_set_demangle_name_func): REmove unused functions.
>   * dwarf2out.h (dwarf2out_set_demangle_name_func): Likewise.
>   * emit-rtl.c (emit_jump_insn_before_noloc): Likewise.
>   (emit_call_insn_before_noloc): Likewise.
>   (emit_barrier_before): Likewise.
>   (emit_call_insn_after_noloc): Likewise.
>   (emit_call_insn_after_setloc): Likewise.
>   (emit_jump_insn_before_setloc): Likewise.
>   (emit_call_insn_before_setloc): Likewise.
>   (emit_call_insn_before): Likewise.
>   * except.c (remove_eh_handler): Likewise.
>   (get_eh_region_from_rtx): Likewise.
>   * except.h (remove_eh_handler): Likewise.
>   (get_eh_region_from_rtx): Likewise.
>   * fold-const.c (div_if_zero_remainder): Likewise.
>   (fold_unary_to_constant): Likewise.
>   * fold-const.h (fold_unary_to_constant): Likewise.
>   (div_if_zero_remainder): Likewise.
>   * function.c (get_hard_reg_initial_reg): Likewise.
>   (get_last_funcdef_no): Likewise.
>   * function.h (get_hard_reg_initial_reg): Likewise.
>   (get_last_funcdef_no): Likewise.
>   * ggc-common.c (ggc_cleared_alloc_htab_ignore_args): Likewise.
>   (ggc_cleared_alloc_ptr_array_two_args): Likewise.
>   (ggc_splay_alloc): Likewise.
>   (ggc_splay_dont_free): Likewise.
>   * gimple-expr.c (is_gimple_address): Likewise.
>   * gimple-expr.h (is_gimple_address): Likewise.
>   * gimple-iterator.c (gsi_for_phi): Likewise.
>   * gimple-iterator.h (gsi_for_phi): Likewise.
>   * gimple-ssa-sprintf.c (struct format_result): Likewise.
>   (format_result::operator+=): Likewise.
>   (struct directive): Likewise.
>   * gimple-ssa-warn-alloca.c (struct alloca_type_and_limit): Likewise.
>   * gimple.c (gimple_unsigned_type): Likewise.
>   (gimple_call_builtin_p): Likewise.
>   * gimple.h (gimple_unsigned_type): Likewise.
>   (gimple_call_builtin_p): Likewise.
>   * gimplify.c (gimple_current_bind_expr): Likewise.
>   * gimplify.h (gimple_current_bind_expr): Likewise.
>   * haifa-sched.c (haifa_classify_insn): Likewise.
>   * hsa-common.c (hsa_add_kernel_dependency): Likewise.
>   (hsa_brig_function_name): Likewise.
>   * hsa-common.h (hsa_add_kernel_dependency): Likewise.
>   (hsa_brig_function_name): Likewise.
>   * ipa-cp.c (ipcp_vr_lattice::meet_with): Likewise.

Interesting, I believe that a class representing a lattice should have a
meet function with its own type.  In this case it would mean moving the
call to ipa_vr_operation_and_type_effects from the caller into the
method to clearly describe the semantics.  But perhaps it does not
matter if we do not have the overload in the meantime.

>   * ipa-devirt.c (vtable_pointer_value_to_binfo): Likewise.
>   * ipa-icf-gimple.c (func_checker::compare_tree_ssa_label): Likewise.
>   * ipa-icf-gimple.h: Likewise.
>   * ipa-icf.c (sem_item::sem_item): Likewise.
>   (sem_function::sem_function): Likewise.
>   (sem_function::icf_handled_component_p): Likewise.
>   (sem_variable::sem_variable): Likewise.
>   * ipa-icf.h: Likewise.
>   * ipa-param-manipulation.c (index

Re: [PATCH] C++: simplify output from suggest_alternatives_for

2018-10-09 Thread Jason Merrill
On Tue, Oct 9, 2018 at 1:19 PM David Malcolm  wrote:
> +  /* Emulation of a "move" constructor, but really a copy
> + constructor.  */
> +
> +  name_hint (const name_hint &other)
> +  : m_suggestion (other.m_suggestion),
> +m_deferred (const_cast (other).take_deferred ())
> +  {
> +  }
> +
> +  /* Emulation of "move" assigment, but really copy assignment.  */
> +
> +  name_hint& operator= (const name_hint &other)
> +  {
> +m_suggestion = other.m_suggestion;
> +m_deferred = const_cast (other).take_deferred ();
> +return *this;
> +  }
> +
> +  /* Take ownership of this name_hint's deferred_diagnostic, for use
> + in chaining up deferred diagnostics.  */
> +  gnu::unique_ptr take_deferred () { return move 
> (m_deferred); }

Why do you want to propagate this hackery into name_hint?  I would
expect the defaulted special member functions to do the right thing
with m_deferred: in -std=c++98 the implicit copy ops call the
gnu::unique_ptr copy ops that actually move, and in -std=c++11 and up
we're calling the move constructor for std::unique_ptr, which does the
right thing.

This also doesn't limit the hack to C++98 mode the way unique-ptr.h does.

Jason


Re: [RFC][PATCH IRA] Fix PR87507, IRA unnecessarily uses non-volatile registers during register assignment

2018-10-09 Thread Vladimir Makarov

On 10/08/2018 03:36 PM, Peter Bergner wrote:

PR87507 shows a problem where IRA assigns a non-volatile TImode reg pair to
a pseudo when there is a volatile reg pair available to use.  This then
causes us to emit save/restore code for the non-volatile reg usage.

The problem here is that the only volatile reg pair that is available is an
odd/even reg pair (r7,r8) and ira-costs.c:ira_tune_allocno_costs() disparages
odd/even reg pairs by increasing their cost.  That's fine, but an even/odd
non-volatile reg pair should still be more expensive than an odd/even reg
pair given the save/restore that we'd need to use it.  However, the costs
used in assign_hard_reg() show that non-volatile reg pair (r30,r31) is
cheaper than odd/even reg pair (r7,r8) (15 versus 1000).  That's a huge
disparity in costs, so looking at where the non-volatile cost comes from,
it comes from the code below in ira-color.c:assign_hard_reg():

if (!HONOR_REG_ALLOC_ORDER)
{
  if ((saved_nregs = calculate_saved_nregs (hard_regno, mode)) != 0)
  /* We need to save/restore the hard register in
 epilogue/prologue.  Therefore we increase the cost.  */
  {
rclass = REGNO_REG_CLASS (hard_regno);
add_cost = ((ira_memory_move_cost[mode][rclass][0]
 + ira_memory_move_cost[mode][rclass][1])
* saved_nregs / hard_regno_nregs (hard_regno,
  mode) - 1);
cost += add_cost;
full_cost += add_cost;
  }
}

I'm not sure I understand the "* saved_nregs / h_r_n (h_r, m) - 1" part
of the calculation.  If saved_nregs is the number of hard regs that
need to be saved for hard_regno in mode MODE (ie, we don't need to
save a hard reg if it's already been saved, etc.), then why aren't we
just multiplying by saved_nregs?  The other problem I see here is
that we're not scaling the cost by the basic block frequency of the
prologue/epilogue, which is what is causing the non-volatile reg
cost to be so low compared to the odd/even volatile reg use, which
is scaled.  However, even if I fix that, improve_allocation() comes
along and undoes it, because it too does not correctly compute the
cost of non-volatiles, so that seems to me that it needs fixing too.
It would be right if we have only one pseudo using non-volatile regs.  
But at this stage we don't know how many pseudos will use the 
non-volatile reg.  Once the non-volotile reg is used, it is free for all 
other pseudo uses (and they can be in hot regions as loops).


The costs were heuristically tuned on SPEC2000 on x86/x86-64.  As the 
functions are bigger (now we have aggressive inlining), the only small 
increase for non-volatile reg works better.  That is why I don't like 
small test RA PRs, the heuristics can be bad for them but they can work 
better for real programs.  When I change this code, I always check SPEC 
because sometimes the results are opposite to the expected ones.


May be you could find better heuristics which works for small and big 
functions.

I have the following work in progress patch I'd like some comments on.
Am I on the right track here?  I noticed that assign_hard_reg() tracks
min_cost and min_full_cost, but min_cost is actually never used for
anything other than setting min_cost, so I removed it.  I also don't
understand why we don't charge non-volatile usage for targets that define
HONOR_REG_ALLOC_ORDER.  Why shouldn't we always account for save/restore
of non-volatile reg usage?
Once min_cost was used for different heuristics.  Still it is useful for 
debugging because full_cost calculations is very complicated (it is 
affected by conflict allocnos preferences and allocnos connected 
directly and indirectly by copies).  Min_cost can be useful in debugging 
to see the picture because its calculation is more straightforward.


A few years ago IRA did not use HONOR_REG_ALLOC_ORDER but people filled 
a PR (I don't remember the number) and that is what behaviour they 
exactly wanted.





[PATCH] Optimize sin(atan(x)) and cos(atan(x)), take 3 (PR tree-optimization/86829)

2018-10-09 Thread Giuliano Augusto Faulin Belinassi
Fixed all issues pointed in the previous iteration.
There is now a significant change regarding how the sin(atan(x))
constant is calculated, as now it checks for which values such that
computing 1 + x*x won't overflow. There are two reasons for this
change: (1) Avoid an intermediate infinity value when optimizing
cos(atan(x)), and (2) avoid the requirement of separate constants for
sin(atan(x)) and cos(atan(x)), thus making easier to maintain the
code.

gcc/ChangeLog

2018-10-09  Giuliano Belinassi  

PR tree-optimization/86829
* match.pd: Added sin(atan(x)) and cos(atan(x)) simplification rules.
* real.c (build_sinatan_real): New function to build a constant equal to the
largest value c such that 1 + c*c will not overflow.
* real.h (build_sinatan_real): Allows this function to be called externally.

gcc/testsuite/gcc.dg/ChangeLog

2018-10-09  Giuliano Belinassi  

PR tree-optimization/86829
* gcc.dg/sinatan-1.c: New test.
* gcc.dg/sinatan-2.c: New test.
* gcc.dg/sinatan-3.c: New test.

There are no tests broken in trunk that seems related to this PR.
Index: gcc/match.pd
===
--- gcc/match.pd	(revision 264941)
+++ gcc/match.pd	(working copy)
@@ -4223,6 +4223,45 @@
(tans (atans @0))
@0)))
 
+ /* Simplify sin(atan(x)) -> x / sqrt(x*x + 1). */
+ (for sins (SIN)
+  atans (ATAN)
+  sqrts (SQRT)
+  copysigns (COPYSIGN)
+  (simplify
+   (sins (atans:s @0))
+   (with
+ {
+  REAL_VALUE_TYPE r_cst;
+  build_sinatan_real (&r_cst, type);
+  tree t_cst = build_real (type, r_cst);
+  tree t_one = build_one_cst (type);
+ }
+(if (SCALAR_FLOAT_TYPE_P (type))
+ (cond (le (abs @0) { t_cst; })
+  (rdiv @0 (sqrts (plus (mult @0 @0) { t_one; })))
+  (copysigns { t_one; } @0))
+
+/* Simplify cos(atan(x)) -> 1 / sqrt(x*x + 1). */
+ (for coss (COS)
+  atans (ATAN)
+  sqrts (SQRT)
+  copysigns (COPYSIGN)
+  (simplify
+   (coss (atans:s @0))
+   (with
+ {
+  REAL_VALUE_TYPE r_cst;
+  build_sinatan_real (&r_cst, type);
+  tree t_cst = build_real (type, r_cst);
+  tree t_one = build_one_cst (type);
+  tree t_zero = build_zero_cst (type);
+ }
+(if (SCALAR_FLOAT_TYPE_P (type))
+ (cond (le (abs @0) { t_cst; })
+  (rdiv { t_one; } (sqrts (plus (mult @0 @0) { t_one; })))
+  (copysigns { t_zero; } @0))
+
 /* cabs(x+0i) or cabs(0+xi) -> abs(x).  */
 (simplify
  (CABS (complex:C @0 real_zerop@1))
Index: gcc/real.c
===
--- gcc/real.c	(revision 264941)
+++ gcc/real.c	(working copy)
@@ -5279,3 +5279,29 @@
 {
   return HONOR_SIGN_DEPENDENT_ROUNDING (GET_MODE (x));
 }
+
+/* Fills r with the largest value such that 1 + r*r won't overflow.
+   This is used in both sin (atan (x)) and cos (atan(x)) optimizations. */
+
+void
+build_sinatan_real (REAL_VALUE_TYPE * r, tree type)
+{
+  REAL_VALUE_TYPE maxval;
+  mpfr_t mpfr_const1, mpfr_c, mpfr_maxval;
+  machine_mode mode = TYPE_MODE (type);
+  const struct real_format * fmt = REAL_MODE_FORMAT (mode);
+
+  real_maxval (&maxval, 0, mode);
+
+  mpfr_inits (mpfr_const1, mpfr_c, mpfr_maxval, NULL);
+
+  mpfr_from_real (mpfr_const1, &dconst1, GMP_RNDN);
+  mpfr_from_real (mpfr_maxval, &maxval,  GMP_RNDN);
+
+  mpfr_sub (mpfr_c, mpfr_maxval, mpfr_const1, GMP_RNDN);
+  mpfr_sqrt (mpfr_c, mpfr_c, GMP_RNDZ);
+
+  real_from_mpfr (r, mpfr_c, fmt, GMP_RNDZ);
+  
+  mpfr_clears (mpfr_const1, mpfr_c, mpfr_maxval, NULL);
+}
Index: gcc/real.h
===
--- gcc/real.h	(revision 264941)
+++ gcc/real.h	(working copy)
@@ -523,4 +523,8 @@
 			   const wide_int_ref &, signop);
 #endif
 
+/* Fills r with the largest value such that 1 + r*r won't overflow.
+   This is used in both sin (atan (x)) and cos (atan(x)) optimizations. */
+extern void build_sinatan_real (REAL_VALUE_TYPE *, tree); 
+
 #endif /* ! GCC_REAL_H */
Index: gcc/testsuite/gcc.dg/sinatan-1.c
===
--- gcc/testsuite/gcc.dg/sinatan-1.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/sinatan-1.c	(working copy)
@@ -0,0 +1,101 @@
+/* { dg-do run } */
+/* { dg-options "-Ofast" } */
+
+extern float sinf (float);
+extern float cosf (float);
+extern float atanf (float);
+extern float sqrtf (float);
+extern float nextafterf (float, float);
+extern double sin (double);
+extern double cos (double);
+extern double atan (double);
+extern double sqrt (double);
+extern double nextafter (double, double);
+extern long double sinl (long double);
+extern long double cosl (long double);
+extern long double atanl (long double);
+extern long double sqrtl (long double);
+extern long double nextafterl (long double, long double);
+
+extern void abort ();
+
+double __attribute__ ((noinline, optimize("Ofast")))
+sinatan (double x)
+{
+return sin (atan (x));
+}
+
+double __attribute__ ((noinl

[committed] Cleanup of libcpp diagnostic callbacks

2018-10-09 Thread David Malcolm
This patch renames the "error" callback within libcpp
to "diagnostic", and uses the pair of enums in cpplib.h, rather
than passing two different kinds of "int" around.

Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.

Committed to trunk as r264999.

gcc/c-family/ChangeLog:
* c-common.c (c_option_controlling_cpp_error): Rename to...
(c_option_controlling_cpp_diagnostic): ...this, and convert
"reason" from int to enum.
(c_cpp_error): Rename to...
(c_cpp_diagnostic): ...this, converting level and reason to enums.
* c-common.h (c_cpp_error): Rename to...
(c_cpp_diagnostic): ...this, converting level and reason to enums.
* c-opts.c (c_common_init_options): Update for renaming.

gcc/fortran/ChangeLog:
* cpp.c (gfc_cpp_init_0): Update for renamings.
(cb_cpp_error): Rename to...
(cb_cpp_diagnostic): ...this, converting level and reason to
enums.

gcc/ChangeLog:
* genmatch.c (error_cb): Rename to...
(diagnostic_cb): ...this, converting int params to enums.
(fatal_at): Update for renaming.
(warning_at): Likewise.
(main): Likewise.
* input.c (selftest::ebcdic_execution_charset::apply):
Update for renaming of...
(selftest::ebcdic_execution_charset::on_error): ...this, renaming
to...
(selftest::ebcdic_execution_charset::on_diagnostic): ...this,
converting level and reason to enums.
(class selftest::lexer_error_sink): Rename to...
(class selftest::lexer_test_options): ...this, renaming field
"m_errors" to "m_diagnostics".
(selftest::lexer_test_options::apply): Update for renaming of...
(selftest::lexer_test_options::on_error): ...this, renaming to...
(selftest::lexer_test_options::on_diagnostic): ...this
converting level and reason to enums.
(selftest::test_lexer_string_locations_raw_string_unterminated):
Update for renamings.
* opth-gen.awk (struct cpp_reason_option_codes_t): Use enum for
"reason".

libcpp/ChangeLog:
* charset.c (noop_error_cb): Rename to...
(noop_diagnostic_cb): ...this, converting params to enums.
(cpp_interpret_string_ranges): Update for renaming and enums.
* directives.c (check_eol_1): Convert reason to enum.
(do_diagnostic): Convert code and reason to enum.
(do_error): Use CPP_W_NONE rather than 0.
(do_pragma_dependency): Likewise.
* errors.c (cpp_diagnostic_at): Convert level and reason to enums.
Update for renaming.
(cpp_diagnostic): Convert level and reason to enums.
(cpp_error): Convert level to enum.
(cpp_warning): Convert reason to enums.
(cpp_pedwarning): Likewise.
(cpp_warning_syshdr): Likewise.
(cpp_diagnostic_with_line): Convert level and reason to enums.
Update for renaming.
(cpp_error_with_line): Convert level to enum.
(cpp_warning_with_line): Convert reason to enums.
(cpp_pedwarning_with_line): Likewise.
(cpp_warning_with_line_syshdr): Likewise.
(cpp_error_at): Convert level to enum.
(cpp_errno): Likewise.
(cpp_errno_filename): Likewise.
* include/cpplib.h (enum cpp_diagnostic_level): Name this enum,
and move to before struct cpp_callbacks.
(enum cpp_warning_reason): Likewise.
(cpp_callbacks::diagnostic): Convert params from int to enums.
(cpp_error): Convert int param to enum cpp_diagnostic_level.
(cpp_warning): Convert int param to enum cpp_warning_reason.
(cpp_pedwarning): Likewise.
(cpp_warning_syshdr): Likewise.
(cpp_errno): Convert int param to enum cpp_diagnostic_level.
(cpp_errno_filename): Likewise.
(cpp_error_with_line): Likewise.
(cpp_warning_with_line): Convert int param to enum
cpp_warning_reason.
(cpp_pedwarning_with_line): Likewise.
(cpp_warning_with_line_syshdr): Likewise.
(cpp_error_at): Convert int param to enum cpp_diagnostic_level.
* macro.c (create_iso_definition): Convert int to enum.
(_cpp_create_definition): Likewise.
---
 gcc/c-family/c-common.c |  17 +++---
 gcc/c-family/c-common.h |   5 +-
 gcc/c-family/c-opts.c   |   2 +-
 gcc/fortran/cpp.c   |  15 +++--
 gcc/genmatch.c  |  15 ++---
 gcc/input.c |  50 +++
 gcc/opth-gen.awk|   6 +-
 libcpp/charset.c|  30 -
 libcpp/directives.c |  12 ++--
 libcpp/errors.c |  66 +++-
 libcpp/include/cpplib.h | 158 ++--
 libcpp/macro.c  |   4 +-
 12 files changed, 207 insertions(+), 173 deletions(-)

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 4bfb145..ac98c9b 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -6068,7 +6068,7 @@ c_parse_error (

Re: introduce --enable-mingw-full32 to default to --large-address-aware

2018-10-09 Thread Alexandre Oliva
On Oct  9, 2018, JonY <10wa...@gmail.com> wrote:

> It is fine to turn it on by default in 32bit MinGW (i686-*-mingw*), but
> leave the defaults as is for others like Cygwin, I am not too sure of
> the effects for Cygwin.

Cygwin already has --large-address-aware enabled, without an option to
disable it.  That makes sense, considering that Cygwin targets Unix
programs, unlikely to have Windows-specific pointer assumptions.

That's why I phrased the option, and implemented it, as specific to
mingw.

Now, if you wish it to affect Cygwin as well, I could implement that,
and drop -mingw from the option name.  I'd retain the current defaults
of each target, unless there's a strong reason to change them.

-- 
Alexandre Oliva, freedom fighter   https://FSFLA.org/blogs/lxo
Be the change, be Free! FSF Latin America board member
GNU Toolchain EngineerFree Software Evangelist


Re: introduce --enable-mingw-full32 to default to --large-address-aware

2018-10-09 Thread JonY
On 10/10/2018 03:24 AM, Alexandre Oliva wrote:
> On Oct  9, 2018, JonY <10wa...@gmail.com> wrote:
> 
>> It is fine to turn it on by default in 32bit MinGW (i686-*-mingw*), but
>> leave the defaults as is for others like Cygwin, I am not too sure of
>> the effects for Cygwin.
> 
> Cygwin already has --large-address-aware enabled, without an option to
> disable it.  That makes sense, considering that Cygwin targets Unix
> programs, unlikely to have Windows-specific pointer assumptions.
> 
> That's why I phrased the option, and implemented it, as specific to
> mingw.
> 
> Now, if you wish it to affect Cygwin as well, I could implement that,
> and drop -mingw from the option name.  I'd retain the current defaults
> of each target, unless there's a strong reason to change them.
> 

In that case, no objections then.



signature.asc
Description: OpenPGP digital signature


Re: introduce --enable-mingw-full32 to default to --large-address-aware

2018-10-09 Thread Alexandre Oliva
On Oct 10, 2018, JonY <10wa...@gmail.com> wrote:

> On 10/10/2018 03:24 AM, Alexandre Oliva wrote:
>> On Oct  9, 2018, JonY <10wa...@gmail.com> wrote:

>> Now, if you wish it to affect Cygwin as well, I could implement that,
>> and drop -mingw from the option name.  I'd retain the current defaults
>> of each target, unless there's a strong reason to change them.

> In that case, no objections then.

Thanks.  Now, before I proceed, please clarify: did you mean you had no
objections to the patch I last proposed, or to the plan in my last
paragraph above?

-- 
Alexandre Oliva, freedom fighter   https://FSFLA.org/blogs/lxo
Be the change, be Free! FSF Latin America board member
GNU Toolchain EngineerFree Software Evangelist


Re: [PATCH] Make std::list::iterator == and != global inline friend

2018-10-09 Thread François Dumont

On 10/09/2018 01:31 PM, Jonathan Wakely wrote:

On 09/10/18 07:25 +0200, François Dumont wrote:
As we talked one day I would like to make all iterator operators 
global for consistency. So here is the patch to do so for std::list 
iterators.


By "global" you mean "non-member", right?


Yes, committed with your advised change.