Re: [PATCH AutoFDO/2]Treat ZERO as common profile probability/count

2018-11-01 Thread bin.cheng
--
Sender:Richard Biener 
Sent at:2018 Oct 31 (Wed) 17:11
To:bin.cheng ; Jan Hubicka 
Cc:GCC Patches 
Subject:Re: [PATCH AutoFDO/2]Treat ZERO as common profile probability/count
> 
> 
> On Wed, Oct 31, 2018 at 7:30 AM bin.cheng  wrote:
>>
>> Hi,
>> In new profile probability/count infra, we have different precision quality 
>> categories,
>> and probabilities/counts of different categories are not supposed to be 
>> compared or
>> calculated.  Though in general is an improvement, it introduces unexpected 
>> behavior.
>> Specifically, class profile_probablity and profile_count themselves are 
>> implemented
>> by comparing probabilities/counts against profile_count::zero().  while 
>> zero() is of
>> profile_precision category, it's always compared different to zero of other 
>> precision
>> categories including afdo.
>>
>> I can see two ways fixing this: 1) Treat zero as a common probability/count 
>> regardless
>> of its category; 2) Provide an "is_zero" method rather than relying on "==" 
>> comparison
>> against probability_count::zero().  2) requires lots of code changes so I 
>> went with 1)
>> in this patch set.  This patch doesn't handle "always" but it might be.
>>
>> This patch also corrects a minor issue where we try to invert an 
>> uninitialized value.
>>
>> Bootstrap and test on x86_64 in patch set.  Is it OK?
> 

Thanks for all the reviews.

> I'll defer on the emit_store_flag_force change, likewise for the zero

As Jeff pointed out too, this is discarded now.

> handling in
> compares - I don't think zeros of different qualities should compare equal.
> Would compares against ::always() not have the very same issue?
> Likewise ::even(),
> ::likely(), etc.?  Those always get guessed quality.

In this version, I went with the second method which adds never_p/zero_p
member function for probability and count.  Check on ZERO value won't fail
unexpected now.  The patch also makes some other changes that avoids
short-circuit returning on ZERO probability/count and let.

> 
> The invert change looks OK to me.  The related change to the always() API 
> would
> suggest to replace guessed_always() with always (guessed) and also do similar
> changes throughout the whole API...
The invert part is split as a standalone patch.  I think adding a default 
precision
parameter to member functions is a little bit better than having various version
functions here, like you mentioned for from_gcov_type.

Bootstrap and test on x86_64 in patch set.  It fixes all (13) ICE autofdo tests.

Thanks,
bin
2018-11-02  Bin Cheng  

* profile-count.h (profile_probability::always): Add parameter.
(profile_probability::invert): Don't invert uninitialized probability.

2018-11-02  Bin Cheng  

* profile-count.h (profile_probability::never_p): New.
(profile_probability::operator+, +=, -, -=, *, *=, /, /=): Check ZERO
probability using never_p.
(profile_probability::apply_scale): Likewise.
(profile_probability::apply): Check using uninitialized_p.
(profile_count::zero_p): New.
(profile_count::compatible_p): Check ZERO count using zero_p.
(profile_count::operator+, +=, <, >, <=, >=, apply_scale): Likewise.
(profile_count::apply_probability, probability_in): Likewise.
(profile_count::operator-, -=): Likewise.  Don't quick return if RHS
profile_count is ZERO.
(profile_count::max): Don't quick return in case of ZERO count.
* profile-count.c (profile_count::to_frequency): Check ZERO profile
probability or count using never_p or zero_p.
(profile_count::to_cgraph_frequency, to_sreal_scale): Likewise.
(profile_count::adjust_for_ipa_scaling): Likewise.
(profile_count::combine_with_ipa_count): Likewise.
(profile_probability::combine_with_count): Likewise.
* bb-reorder.c (sanitize_hot_paths): Likewise.
* cfg.c (update_bb_profile_for_threading): Likewise.
(scale_bbs_frequencies_profile_count): Likewise.
* ipa-profile.c (ipa_propagate_frequency_1): Likewise.
(ipa_propagate_frequency): Likewise.
* ipa-utility.c (ipa_merge_profiles): Likewise.
* predict.c (maybe_hot_count_p, probably_never_executed): Likewise.
(probably_never_executed_bb_p, unlikely_executed_stmt_p): Likewise.
(combine_predictions_for_bb): Likewise.
(drop_profile, handle_missing_profiles): Likewise.
(propagate_unlikely_bbs_forward): Likewise.
(determine_unlikely_bbs): Likewise.
(estimate_bb_frequencies): Likewise.
(compute_function_frequency, force_edge_cold): Likewise.
* profile.c (compute_branch_probabilities): Likewise.
* shrink-wrap.c (try_shrink_wrapping): Likewise.
* tree-ssa-loop-manip.c (scale_dominated_blocks_in_loop): Likewise.
(tree_transform_and_unroll_loop): Likewise.
* tree-ssa-threadupdate.c (u

Re: [build] Remove SPARC HAVE_AS_REGISTER_PSEUDO_OP

2018-11-01 Thread Eric Botcazou
> So the current patch removes both the autoconf test and the uses of the
> macro.  Solaris 11/SPARC Bootstraps with both as and gas currently
> running.  Ok for mainline if they pass?

Sure, thanks for fixing this!

-- 
Eric Botcazou


Re: C++ PATCH to Implement P0846R0, ADL and function templates [v4]

2018-11-01 Thread Marek Polacek
On Thu, Nov 01, 2018 at 04:26:34PM -0400, Jason Merrill wrote:
> > @@ -16319,6 +16359,25 @@ cp_parser_template_name (cp_parser* parser,
> > if (TREE_CODE (*iter) == TEMPLATE_DECL)
> >   found = true;
> >
> > +  if (!found
> > + && (cxx_dialect > cxx17)
> > + && !scoped_p
> > + && cp_lexer_next_token_is (parser->lexer, CPP_LESS))
> > +   {
> > + /* [temp.names] says "A name is also considered to refer to a 
> > template
> > +if it is an unqualified-id followed by a < and name lookup 
> > finds
> > +either one or more functions or finds nothing."  */
> > +
> > + /* The "more functions" case.  Just use the OVERLOAD as normally. 
> >  */
> > + if (TREE_CODE (decl) == OVERLOAD
> > + /* Name lookup found one function.  */
> > + || TREE_CODE (decl) == FUNCTION_DECL)
> > +   found = true;
> 
> Is this specifically not using is_overloaded_fn to avoid considering
> BASELINK?  That should be mentioned in a comment.

Yeah, I thought we could not get a member function here so I didn't use
is_overloaded_fn.  I've added a comment to that effect.

> OK with that change.

And so this is what I'll commit momentarily:

2018-11-01  Marek Polacek  

Implement P0846R0, ADL and function templates.
* decl.c (grokfndecl): Allow FUNCTION_DECL in assert.
* lex.c (unqualified_fn_lookup_error): Handle TEMPLATE_ID_EXPR.
* parser.c (cp_parser_postfix_expression): Do ADL for a template-name.
(cp_parser_template_id): Give errors if parsing the template argument
list didn't go well.  Allow FUNCTION_DECL in assert.
(cp_parser_template_name): Consider a name to refer to a template if
it is an unqualified-id followed by a <.  Don't return the identifier
if the decl is a function and dependent.
* pt.c (tsubst_copy) : Remove assert.

* g++.dg/addr_builtin-1.C: Adjust dg-error.
* g++.dg/cpp2a/fn-template1.C: New test.
* g++.dg/cpp2a/fn-template10.C: New test.
* g++.dg/cpp2a/fn-template11.C: New test.
* g++.dg/cpp2a/fn-template12.C: New test.
* g++.dg/cpp2a/fn-template13.C: New test.
* g++.dg/cpp2a/fn-template14.C: New test.
* g++.dg/cpp2a/fn-template15.C: New test.
* g++.dg/cpp2a/fn-template16.C: New test.
* g++.dg/cpp2a/fn-template2.C: New test.
* g++.dg/cpp2a/fn-template3.C: New test.
* g++.dg/cpp2a/fn-template4.C: New test.
* g++.dg/cpp2a/fn-template5.C: New test.
* g++.dg/cpp2a/fn-template6.C: New test.
* g++.dg/cpp2a/fn-template7.C: New test.
* g++.dg/cpp2a/fn-template8.C: New test.
* g++.dg/cpp2a/fn-template9.C: New test.
* g++.dg/parse/fn-template1.C: New test.
* g++.dg/parse/fn-template2.C: New test.
* g++.dg/parse/template19.C: Adjust dg-error.
* g++.dg/template/pr61745.C: Add target to dg-error.

diff --git gcc/cp/decl.c gcc/cp/decl.c
index 23fcf6b0471..f0033dd5458 100644
--- gcc/cp/decl.c
+++ gcc/cp/decl.c
@@ -8857,7 +8857,9 @@ grokfndecl (tree ctype,
 the information in the TEMPLATE_ID_EXPR.  */
  SET_DECL_IMPLICIT_INSTANTIATION (decl);
 
- gcc_assert (identifier_p (fns) || TREE_CODE (fns) == OVERLOAD);
+ gcc_assert (identifier_p (fns)
+ || TREE_CODE (fns) == OVERLOAD
+ || TREE_CODE (fns) == FUNCTION_DECL);
  DECL_TEMPLATE_INFO (decl) = build_template_info (fns, args);
 
  for (t = TYPE_ARG_TYPES (TREE_TYPE (decl)); t; t = TREE_CHAIN (t))
diff --git gcc/cp/lex.c gcc/cp/lex.c
index 410dfd1bc5b..26ec52f3498 100644
--- gcc/cp/lex.c
+++ gcc/cp/lex.c
@@ -541,6 +541,9 @@ unqualified_fn_lookup_error (cp_expr name_expr)
   if (loc == UNKNOWN_LOCATION)
 loc = input_location;
 
+  if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
+name = TREE_OPERAND (name, 0);
+
   if (processing_template_decl)
 {
   /* In a template, it is invalid to write "f()" or "f(3)" if no
diff --git gcc/cp/parser.c gcc/cp/parser.c
index 206ceb048d4..d01c92431ef 100644
--- gcc/cp/parser.c
+++ gcc/cp/parser.c
@@ -7195,7 +7195,11 @@ cp_parser_postfix_expression (cp_parser *parser, bool 
address_p, bool cast_p,
if (idk == CP_ID_KIND_UNQUALIFIED
|| idk == CP_ID_KIND_TEMPLATE_ID)
  {
-   if (identifier_p (postfix_expression))
+   if (identifier_p (postfix_expression)
+   /* In C++2A, we may need to perform ADL for a template
+  name.  */
+   || (TREE_CODE (postfix_expression) == TEMPLATE_ID_EXPR
+   && identifier_p (TREE_OPERAND (postfix_expression, 0
  {
if (!args->is_empty ())
  {
@@ -16029,6 +16033,37 @@ cp_parser_template_id (cp_parser *parser,
}
   /* Parse the arguments.  */
   arguments = cp_p

Re: [PATCH 2/2 v3][IRA,LRA] Fix PR86939, IRA incorrectly creates an interference between a pseudo register and a hard register

2018-11-01 Thread Peter Bergner
On 11/1/18 1:50 PM, Renlin Li wrote:
> Is there any update on this issues?
> arm-none-linux-gnueabihf native toolchain has been mis-compiled for a while.

>From the analysis I've done, my commit is just exposing latent issues
in LRA.  Can you try the patch I submitted here to see if it helps?

  https://gcc.gnu.org/ml/gcc-patches/2018-10/msg01757.html

It survives on powerpc64le-linux, x86_64-linux and s390x-linux.
Jeff threw it on his testers and said he saw an arm issue and was
trying to come up with a test case for me to debug.

The specific issue you mentioned with the inline asm and the casp insn
is a bug in LRA where is will spill a user defined hard register and
it shouldn't do that.  My patch above stops that.  The question is
whether we've quashed the rest of the latent bugs.

Peter




Re: [PATCH, OpenACC 2.5, libgomp] Add *_async versions of runtime library API functions

2018-11-01 Thread Thomas Schwinge
Hi Chung-Lin!

On Mon, 10 Sep 2018 23:04:18 +0800, Chung-Lin Tang  
wrote:
> This patch adds *_async versions of several OpenACC runtime library API 
> functions,
> which is to allow execution of a function asynchronously on particular async
> stream, an addition to the standard since 2.5. Specifically, these functions:
> 
> acc_copyin_async
> acc_copyout_async
> acc_copyout_finalize_async
> acc_create_async
> acc_delete_async
> acc_delete_finalize_async
> acc_memcpy_from_device_async
> acc_memcpy_to_device_async
> acc_update_device_async
> acc_update_self_async
> 
> which have an additional 'int async' argument in additional from the 
> non-async version.
> 
> libgomp tested with offloading with no regressions, is this okay for trunk?

Thanks, approved.  To record the review effort, please include
"Reviewed-by: Thomas Schwinge " in the commit
log, see .


Grüße
 Thomas


> 2018-09-10  Chung-Lin Tang  
> 
>  libgomp/
>  * oacc-mem.c (memcpy_tofrom_device): New function, combined from
>  acc_memcpy_to/from_device functions, now with async parameter.
>  (acc_memcpy_to_device): Modify to use memcpy_tofrom_device.
>  (acc_memcpy_from_device): Likewise.
>  (acc_memcpy_to_device_async): New API function.
>  (acc_memcpy_from_device_async): Likewise.
>  (present_create_copy): Add async parameter and async 
> setting/unsetting.
>  (acc_create): Adjust present_create_copy call.
>  (acc_copyin): Likewise.
>  (acc_present_or_create): Likewise.
>  (acc_present_or_copyin): Likewise.
>  (acc_create_async): New API function.
>  (acc_copyin_async): New API function.
>  (delete_copyout): Add async parameter and async setting/unsetting.
>  (acc_delete): Adjust delete_copyout call.
>  (acc_copyout): Likewise.
>  (acc_delete_async): New API function.
>  (acc_copyout_async): Likewise.
>  (update_dev_host): Add async parameter and async setting/unsetting.
>  (acc_update_device): Adjust update_dev_host call.
>  (acc_update_self): Likewise.
>  (acc_update_device_async): New API function.
>  (acc_update_self_async): Likewise.
>  * openacc.h (acc_copyin_async): Declare new API function.
>  (acc_create_async): Likewise.
>  (acc_copyout_async): Likewise.
>  (acc_delete_async): Likewise.
>  (acc_update_device_async): Likewise.
>  (acc_update_self_async): Likewise.
>  (acc_memcpy_to_device_async): Likewise.
>  (acc_memcpy_from_device_async): Likewise.
>  * openacc_lib.h (acc_copyin_async_32_h): New subroutine.
>  (acc_copyin_async_64_h): New subroutine.
>  (acc_copyin_async_array_h): New subroutine.
>  (acc_create_async_32_h): New subroutine.
>  (acc_create_async_64_h): New subroutine.
>  (acc_create_async_array_h): New subroutine.
>  (acc_copyout_async_32_h): New subroutine.
>  (acc_copyout_async_64_h): New subroutine.
>  (acc_copyout_async_array_h): New subroutine.
>  (acc_delete_async_32_h): New subroutine.
>  (acc_delete_async_64_h): New subroutine.
>  (acc_delete_async_array_h): New subroutine.
>  (acc_update_device_async_32_h): New subroutine.
>  (acc_update_device_async_64_h): New subroutine.
>  (acc_update_device_async_array_h): New subroutine.
>  (acc_update_self_async_32_h): New subroutine.
>  (acc_update_self_async_64_h): New subroutine.
>  (acc_update_self_async_array_h): New subroutine.
>  * openacc.f90 (acc_copyin_async_32_h): New subroutine.
>  (acc_copyin_async_64_h): New subroutine.
>  (acc_copyin_async_array_h): New subroutine.
>  (acc_create_async_32_h): New subroutine.
>  (acc_create_async_64_h): New subroutine.
>  (acc_create_async_array_h): New subroutine.
>  (acc_copyout_async_32_h): New subroutine.
>  (acc_copyout_async_64_h): New subroutine.
>  (acc_copyout_async_array_h): New subroutine.
>  (acc_delete_async_32_h): New subroutine.
>  (acc_delete_async_64_h): New subroutine.
>  (acc_delete_async_array_h): New subroutine.
>  (acc_update_device_async_32_h): New subroutine.
>  (acc_update_device_async_64_h): New subroutine.
>  (acc_update_device_async_array_h): New subroutine.
>  (acc_update_self_async_32_h): New subroutine.
>  (acc_update_self_async_64_h): New subroutine.
>  (acc_update_self_async_array_h): New subroutine.
>  * libgomp.map (OACC_2.5): Add acc_copyin_async*, acc_copyout_async*,
>  acc_copyout_finalize_async*, acc_create_async*, acc_delete_async*,
>  acc_delete_finalize_async*, acc_memcpy_from_device_async*,
>  acc_memcpy_to_device_async*, acc_update_device_async*, and
>  acc_update_self_a

[PATCH, AArch64, v3 5/6] aarch64: Implement -matomic-ool

2018-11-01 Thread Richard Henderson
* config/aarch64/aarch64.opt (-matomic-ool): New.
* config/aarch64/aarch64.c (aarch64_atomic_ool_func): New.
(aarch64_ool_cas_names, aarch64_ool_swp_names): New.
(aarch64_ool_ldadd_names, aarch64_ool_ldset_names): New.
(aarch64_ool_ldclr_names, aarch64_ool_ldeor_names): New.
(aarch64_expand_compare_and_swap): Honor TARGET_ATOMIC_OOL.
* config/aarch64/atomics.md (atomic_exchange): Likewise.
(atomic_): Likewise.
(atomic_fetch_): Likewise.
(atomic__fetch): Likewise.
---
 gcc/config/aarch64/aarch64-protos.h   | 13 +++
 gcc/config/aarch64/aarch64.c  | 87 +
 .../atomic-comp-swap-release-acquire.c|  2 +-
 .../gcc.target/aarch64/atomic-op-acq_rel.c|  2 +-
 .../gcc.target/aarch64/atomic-op-acquire.c|  2 +-
 .../gcc.target/aarch64/atomic-op-char.c   |  2 +-
 .../gcc.target/aarch64/atomic-op-consume.c|  2 +-
 .../gcc.target/aarch64/atomic-op-imm.c|  2 +-
 .../gcc.target/aarch64/atomic-op-int.c|  2 +-
 .../gcc.target/aarch64/atomic-op-long.c   |  2 +-
 .../gcc.target/aarch64/atomic-op-relaxed.c|  2 +-
 .../gcc.target/aarch64/atomic-op-release.c|  2 +-
 .../gcc.target/aarch64/atomic-op-seq_cst.c|  2 +-
 .../gcc.target/aarch64/atomic-op-short.c  |  2 +-
 .../aarch64/atomic_cmp_exchange_zero_reg_1.c  |  2 +-
 .../atomic_cmp_exchange_zero_strong_1.c   |  2 +-
 .../gcc.target/aarch64/sync-comp-swap.c   |  2 +-
 .../gcc.target/aarch64/sync-op-acquire.c  |  2 +-
 .../gcc.target/aarch64/sync-op-full.c |  2 +-
 gcc/config/aarch64/aarch64.opt|  4 +
 gcc/config/aarch64/atomics.md | 94 +--
 gcc/doc/invoke.texi   | 14 ++-
 22 files changed, 220 insertions(+), 26 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-protos.h 
b/gcc/config/aarch64/aarch64-protos.h
index 1fe1a50d52a..1c1877cd200 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -630,4 +630,17 @@ poly_uint64 aarch64_regmode_natural_size (machine_mode);
 
 bool aarch64_high_bits_all_ones_p (HOST_WIDE_INT);
 
+struct atomic_ool_names
+{
+const char *str[5][4];
+};
+
+rtx aarch64_atomic_ool_func(machine_mode mode, rtx model_rtx,
+   const atomic_ool_names *names);
+extern const atomic_ool_names aarch64_ool_swp_names;
+extern const atomic_ool_names aarch64_ool_ldadd_names;
+extern const atomic_ool_names aarch64_ool_ldset_names;
+extern const atomic_ool_names aarch64_ool_ldclr_names;
+extern const atomic_ool_names aarch64_ool_ldeor_names;
+
 #endif /* GCC_AARCH64_PROTOS_H */
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index b29f437aeaf..9ab8b95c344 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -14679,6 +14679,82 @@ aarch64_emit_unlikely_jump (rtx insn)
   add_reg_br_prob_note (jump, profile_probability::very_unlikely ());
 }
 
+/* We store the names of the various atomic helpers in a 5x4 array.
+   Return the libcall function given MODE, MODEL and NAMES.  */
+
+rtx
+aarch64_atomic_ool_func(machine_mode mode, rtx model_rtx,
+   const atomic_ool_names *names)
+{
+  memmodel model = memmodel_base (INTVAL (model_rtx));
+  int mode_idx, model_idx;
+
+  switch (mode)
+{
+case E_QImode:
+  mode_idx = 0;
+  break;
+case E_HImode:
+  mode_idx = 1;
+  break;
+case E_SImode:
+  mode_idx = 2;
+  break;
+case E_DImode:
+  mode_idx = 3;
+  break;
+case E_TImode:
+  mode_idx = 4;
+  break;
+default:
+  gcc_unreachable ();
+}
+
+  switch (model)
+{
+case MEMMODEL_RELAXED:
+  model_idx = 0;
+  break;
+case MEMMODEL_CONSUME:
+case MEMMODEL_ACQUIRE:
+  model_idx = 1;
+  break;
+case MEMMODEL_RELEASE:
+  model_idx = 2;
+  break;
+case MEMMODEL_ACQ_REL:
+case MEMMODEL_SEQ_CST:
+  model_idx = 3;
+  break;
+default:
+  gcc_unreachable ();
+}
+
+  return init_one_libfunc_visibility (names->str[mode_idx][model_idx],
+ VISIBILITY_HIDDEN);
+}
+
+#define DEF0(B, N) \
+  { "__aa64_" #B #N "_relax", \
+"__aa64_" #B #N "_acq", \
+"__aa64_" #B #N "_rel", \
+"__aa64_" #B #N "_acq_rel" }
+
+#define DEF4(B)  DEF0(B, 1), DEF0(B, 2), DEF0(B, 4), DEF0(B, 8), \
+{ NULL, NULL, NULL, NULL }
+#define DEF5(B)  DEF0(B, 1), DEF0(B, 2), DEF0(B, 4), DEF0(B, 8), DEF0(B, 16)
+
+static const atomic_ool_names aarch64_ool_cas_names = { { DEF5(cas) } };
+const atomic_ool_names aarch64_ool_swp_names = { { DEF4(swp) } };
+const atomic_ool_names aarch64_ool_ldadd_names = { { DEF4(ldadd) } };
+const atomic_ool_names aarch64_ool_ldset_names = { { DEF4(ldset) } };
+const atomic_ool_names aarch64_ool_ldclr_names = { { DEF4(ldclr) } };
+const atomic_ool_names aarch64_ool_ldeor_names = { { DEF4(ldeor) } };

[PATCH, AArch64, v3 4/6] aarch64: Add out-of-line functions for LSE atomics

2018-11-01 Thread Richard Henderson
This is the libgcc part of the interface -- providing the functions.
Rationale is provided at the top of libgcc/config/aarch64/lse.S.

* config/aarch64/lse-init.c: New file.
* config/aarch64/lse.S: New file.
* config/aarch64/t-lse: New file.
* config.host: Add t-lse to all aarch64 tuples.
---
 libgcc/config/aarch64/lse-init.c |  45 ++
 libgcc/config.host   |   4 +
 libgcc/config/aarch64/lse.S  | 238 +++
 libgcc/config/aarch64/t-lse  |  44 ++
 4 files changed, 331 insertions(+)
 create mode 100644 libgcc/config/aarch64/lse-init.c
 create mode 100644 libgcc/config/aarch64/lse.S
 create mode 100644 libgcc/config/aarch64/t-lse

diff --git a/libgcc/config/aarch64/lse-init.c b/libgcc/config/aarch64/lse-init.c
new file mode 100644
index 000..03b4e1e8ea8
--- /dev/null
+++ b/libgcc/config/aarch64/lse-init.c
@@ -0,0 +1,45 @@
+/* Out-of-line LSE atomics for AArch64 architecture, Init.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   Contributed by Linaro Ltd.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+.  */
+
+/* Define the symbol gating the LSE implementations.  */
+extern _Bool __aa64_have_atomics
+__attribute__((visibility("hidden"), nocommon));
+
+/* Disable initialization of __aa64_have_atomics during bootstrap.  */
+#ifndef inhibit_libc
+# include 
+
+/* Disable initialization if the system headers are too old.  */
+# if defined(AT_HWCAP) && defined(HWCAP_ATOMICS)
+
+static void __attribute__((constructor))
+init_have_atomics (void)
+{
+  unsigned long hwcap = getauxval (AT_HWCAP);
+  __aa64_have_atomics = (hwcap & HWCAP_ATOMICS) != 0;
+}
+
+# endif /* HWCAP */
+#endif /* inhibit_libc */
diff --git a/libgcc/config.host b/libgcc/config.host
index 029f6569caf..7e9a8b6bc8f 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -340,23 +340,27 @@ aarch64*-*-elf | aarch64*-*-rtems*)
extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o"
extra_parts="$extra_parts crtfastmath.o"
tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
+   tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc"
tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm"
md_unwind_header=aarch64/aarch64-unwind.h
;;
 aarch64*-*-freebsd*)
extra_parts="$extra_parts crtfastmath.o"
tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
+   tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc"
tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm"
md_unwind_header=aarch64/freebsd-unwind.h
;;
 aarch64*-*-fuchsia*)
tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
+   tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc"
tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp"
;;
 aarch64*-*-linux*)
extra_parts="$extra_parts crtfastmath.o"
md_unwind_header=aarch64/linux-unwind.h
tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
+   tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc"
tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm"
;;
 alpha*-*-linux*)
diff --git a/libgcc/config/aarch64/lse.S b/libgcc/config/aarch64/lse.S
new file mode 100644
index 000..3e42a6569af
--- /dev/null
+++ b/libgcc/config/aarch64/lse.S
@@ -0,0 +1,238 @@
+/* Out-of-line LSE atomics for AArch64 architecture.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   Contributed by Linaro Ltd.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Except

[PATCH, AArch64, v3 6/6] Enable -matomic-ool by default

2018-11-01 Thread Richard Henderson
Do Not Merge Upstream.
This is for agraf and his testing within SLES.
---
 gcc/common/config/aarch64/aarch64-common.c | 6 --
 gcc/config/aarch64/aarch64.c   | 6 --
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/gcc/common/config/aarch64/aarch64-common.c 
b/gcc/common/config/aarch64/aarch64-common.c
index dd7d4267340..a916df3bcbe 100644
--- a/gcc/common/config/aarch64/aarch64-common.c
+++ b/gcc/common/config/aarch64/aarch64-common.c
@@ -32,9 +32,11 @@
 #include "diagnostic.h"
 #include "params.h"
 
-#ifdef  TARGET_BIG_ENDIAN_DEFAULT
 #undef  TARGET_DEFAULT_TARGET_FLAGS
-#define TARGET_DEFAULT_TARGET_FLAGS (MASK_BIG_END)
+#ifdef  TARGET_BIG_ENDIAN_DEFAULT
+#define TARGET_DEFAULT_TARGET_FLAGS (MASK_BIG_END | MASK_ATOMIC_OOL)
+#else
+#define TARGET_DEFAULT_TARGET_FLAGS (MASK_ATOMIC_OOL)
 #endif
 
 #undef  TARGET_HANDLE_OPTION
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 9ab8b95c344..b60f364799d 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -18043,9 +18043,11 @@ aarch64_run_selftests (void)
 #undef TARGET_C_MODE_FOR_SUFFIX
 #define TARGET_C_MODE_FOR_SUFFIX aarch64_c_mode_for_suffix
 
-#ifdef TARGET_BIG_ENDIAN_DEFAULT
 #undef  TARGET_DEFAULT_TARGET_FLAGS
-#define TARGET_DEFAULT_TARGET_FLAGS (MASK_BIG_END)
+#ifdef  TARGET_BIG_ENDIAN_DEFAULT
+#define TARGET_DEFAULT_TARGET_FLAGS (MASK_BIG_END | MASK_ATOMIC_OOL)
+#else
+#define TARGET_DEFAULT_TARGET_FLAGS (MASK_ATOMIC_OOL)
 #endif
 
 #undef TARGET_CLASS_MAX_NREGS
-- 
2.17.2



[PATCH, AArch64, v3 3/6] aarch64: Tidy aarch64_split_compare_and_swap

2018-11-01 Thread Richard Henderson
From: Richard Henderson 

With aarch64_track_speculation, we had extra code to do exactly what the
!strong_zero_p path already did.  The rest is reducing code duplication.

* config/aarch64/aarch64 (aarch64_split_compare_and_swap): Disable
strong_zero_p for aarch64_track_speculation; unify some code paths;
use aarch64_gen_compare_reg instead of open-coding.
---
 gcc/config/aarch64/aarch64.c | 50 ++--
 1 file changed, 14 insertions(+), 36 deletions(-)

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 942f2037235..b29f437aeaf 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -14767,13 +14767,11 @@ aarch64_emit_post_barrier (enum memmodel model)
 void
 aarch64_split_compare_and_swap (rtx operands[])
 {
-  rtx rval, mem, oldval, newval, scratch;
+  rtx rval, mem, oldval, newval, scratch, x, model_rtx;
   machine_mode mode;
   bool is_weak;
   rtx_code_label *label1, *label2;
-  rtx x, cond;
   enum memmodel model;
-  rtx model_rtx;
 
   rval = operands[0];
   mem = operands[1];
@@ -14794,7 +14792,8 @@ aarch64_split_compare_and_swap (rtx operands[])
CBNZscratch, .label1
 .label2:
CMP rval, 0.  */
-  bool strong_zero_p = !is_weak && oldval == const0_rtx && mode != TImode;
+  bool strong_zero_p = (!is_weak && !aarch64_track_speculation &&
+   oldval == const0_rtx && mode != TImode);
 
   label1 = NULL;
   if (!is_weak)
@@ -14807,35 +14806,20 @@ aarch64_split_compare_and_swap (rtx operands[])
   /* The initial load can be relaxed for a __sync operation since a final
  barrier will be emitted to stop code hoisting.  */
   if (is_mm_sync (model))
-aarch64_emit_load_exclusive (mode, rval, mem,
-GEN_INT (MEMMODEL_RELAXED));
+aarch64_emit_load_exclusive (mode, rval, mem, GEN_INT (MEMMODEL_RELAXED));
   else
 aarch64_emit_load_exclusive (mode, rval, mem, model_rtx);
 
   if (strong_zero_p)
-{
-  if (aarch64_track_speculation)
-   {
- /* Emit an explicit compare instruction, so that we can correctly
-track the condition codes.  */
- rtx cc_reg = aarch64_gen_compare_reg (NE, rval, const0_rtx);
- x = gen_rtx_NE (GET_MODE (cc_reg), cc_reg, const0_rtx);
-   }
-  else
-   x = gen_rtx_NE (VOIDmode, rval, const0_rtx);
-
-  x = gen_rtx_IF_THEN_ELSE (VOIDmode, x,
-   gen_rtx_LABEL_REF (Pmode, label2), pc_rtx);
-  aarch64_emit_unlikely_jump (gen_rtx_SET (pc_rtx, x));
-}
+x = gen_rtx_NE (VOIDmode, rval, const0_rtx);
   else
 {
-  cond = aarch64_gen_compare_reg_maybe_ze (NE, rval, oldval, mode);
-  x = gen_rtx_NE (VOIDmode, cond, const0_rtx);
-  x = gen_rtx_IF_THEN_ELSE (VOIDmode, x,
-   gen_rtx_LABEL_REF (Pmode, label2), pc_rtx);
-  aarch64_emit_unlikely_jump (gen_rtx_SET (pc_rtx, x));
+  rtx cc_reg = aarch64_gen_compare_reg_maybe_ze (NE, rval, oldval, mode);
+  x = gen_rtx_NE (VOIDmode, cc_reg, const0_rtx);
 }
+  x = gen_rtx_IF_THEN_ELSE (VOIDmode, x,
+   gen_rtx_LABEL_REF (Pmode, label2), pc_rtx);
+  aarch64_emit_unlikely_jump (gen_rtx_SET (pc_rtx, x));
 
   aarch64_emit_store_exclusive (mode, scratch, mem, newval, model_rtx);
 
@@ -14856,22 +14840,16 @@ aarch64_split_compare_and_swap (rtx operands[])
   aarch64_emit_unlikely_jump (gen_rtx_SET (pc_rtx, x));
 }
   else
-{
-  cond = gen_rtx_REG (CCmode, CC_REGNUM);
-  x = gen_rtx_COMPARE (CCmode, scratch, const0_rtx);
-  emit_insn (gen_rtx_SET (cond, x));
-}
+aarch64_gen_compare_reg (NE, scratch, const0_rtx);
 
   emit_label (label2);
+
   /* If we used a CBNZ in the exchange loop emit an explicit compare with RVAL
  to set the condition flags.  If this is not used it will be removed by
  later passes.  */
   if (strong_zero_p)
-{
-  cond = gen_rtx_REG (CCmode, CC_REGNUM);
-  x = gen_rtx_COMPARE (CCmode, rval, const0_rtx);
-  emit_insn (gen_rtx_SET (cond, x));
-}
+aarch64_gen_compare_reg (NE, rval, const0_rtx);
+
   /* Emit any final barrier needed for a __sync operation.  */
   if (is_mm_sync (model))
 aarch64_emit_post_barrier (model);
-- 
2.17.2



[PATCH, AArch64, v3 2/6] aarch64: Implement TImode compare-and-swap

2018-11-01 Thread Richard Henderson
From: Richard Henderson 

This pattern will only be used with the __sync functions, because
we do not yet have a bare TImode atomic load.

* config/aarch64/aarch64.c (aarch64_gen_compare_reg): Add support
for NE comparison of TImode values.
(aarch64_emit_load_exclusive): Add support for TImode.
(aarch64_emit_store_exclusive): Likewise.
(aarch64_split_compare_and_swap): Disable strong_zero_p for TImode.
* config/aarch64/atomics.md (@atomic_compare_and_swap):
Change iterator from ALLI to ALLI_TI.
(@atomic_compare_and_swap): New.
(@atomic_compare_and_swap_lse): New.
(aarch64_load_exclusive_pair): New.
(aarch64_store_exclusive_pair): New.
* config/aarch64/iterators.md (JUST_TI): New.
---
 gcc/config/aarch64/aarch64.c| 55 +---
 gcc/config/aarch64/atomics.md   | 91 +++--
 gcc/config/aarch64/iterators.md |  3 ++
 3 files changed, 137 insertions(+), 12 deletions(-)

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 930f27d9bac..942f2037235 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -1611,10 +1611,40 @@ emit_set_insn (rtx x, rtx y)
 rtx
 aarch64_gen_compare_reg (RTX_CODE code, rtx x, rtx y)
 {
-  machine_mode mode = SELECT_CC_MODE (code, x, y);
-  rtx cc_reg = gen_rtx_REG (mode, CC_REGNUM);
+  machine_mode cmp_mode;
+  machine_mode cc_mode;
+  rtx cc_reg;
 
-  emit_set_insn (cc_reg, gen_rtx_COMPARE (mode, x, y));
+  if (swap_commutative_operands_p (x, y))
+{
+  code = swap_condition (code);
+  std::swap (x, y);
+}
+  cmp_mode = GET_MODE (x);
+
+  if (cmp_mode == TImode)
+{
+  gcc_assert (code == NE);
+
+  cc_mode = CCmode;
+  cc_reg = gen_rtx_REG (cc_mode, CC_REGNUM);
+
+  rtx x_lo = operand_subword (x, 0, 0, TImode);
+  rtx y_lo = operand_subword (y, 0, 0, TImode);
+  emit_set_insn (cc_reg, gen_rtx_COMPARE (cc_mode, x_lo, y_lo));
+
+  rtx x_hi = operand_subword (x, 1, 0, TImode);
+  rtx y_hi = operand_subword (y, 1, 0, TImode);
+  emit_insn (gen_ccmpdi (cc_reg, cc_reg, x_hi, y_hi,
+gen_rtx_EQ (cc_mode, cc_reg, const0_rtx),
+GEN_INT (AARCH64_EQ)));
+}
+  else
+{
+  cc_mode = SELECT_CC_MODE (code, x, y);
+  cc_reg = gen_rtx_REG (cc_mode, CC_REGNUM);
+  emit_set_insn (cc_reg, gen_rtx_COMPARE (cc_mode, x, y));
+}
   return cc_reg;
 }
 
@@ -2162,7 +2192,6 @@ aarch64_zero_extend_const_eq (machine_mode xmode, rtx x,
   gcc_assert (r != NULL);
   return rtx_equal_p (x, r);
 }
- 
 
 static rtx
 aarch64_force_temporary (machine_mode mode, rtx x, rtx value)
@@ -14619,16 +14648,26 @@ static void
 aarch64_emit_load_exclusive (machine_mode mode, rtx rval,
 rtx mem, rtx model_rtx)
 {
-  emit_insn (gen_aarch64_load_exclusive (mode, rval, mem, model_rtx));
+  if (mode == TImode)
+emit_insn (gen_aarch64_load_exclusive_pair (gen_lowpart (DImode, rval),
+   gen_highpart (DImode, rval),
+   mem, model_rtx));
+  else
+emit_insn (gen_aarch64_load_exclusive (mode, rval, mem, model_rtx));
 }
 
 /* Emit store exclusive.  */
 
 static void
 aarch64_emit_store_exclusive (machine_mode mode, rtx bval,
- rtx rval, rtx mem, rtx model_rtx)
+ rtx mem, rtx rval, rtx model_rtx)
 {
-  emit_insn (gen_aarch64_store_exclusive (mode, bval, rval, mem, model_rtx));
+  if (mode == TImode)
+emit_insn (gen_aarch64_store_exclusive_pair
+  (bval, mem, operand_subword (rval, 0, 0, TImode),
+   operand_subword (rval, 1, 0, TImode), model_rtx));
+  else
+emit_insn (gen_aarch64_store_exclusive (mode, bval, mem, rval, model_rtx));
 }
 
 /* Mark the previous jump instruction as unlikely.  */
@@ -14755,7 +14794,7 @@ aarch64_split_compare_and_swap (rtx operands[])
CBNZscratch, .label1
 .label2:
CMP rval, 0.  */
-  bool strong_zero_p = !is_weak && oldval == const0_rtx;
+  bool strong_zero_p = !is_weak && oldval == const0_rtx && mode != TImode;
 
   label1 = NULL;
   if (!is_weak)
diff --git a/gcc/config/aarch64/atomics.md b/gcc/config/aarch64/atomics.md
index 00f7af4e4ac..08a3a1ff955 100644
--- a/gcc/config/aarch64/atomics.md
+++ b/gcc/config/aarch64/atomics.md
@@ -22,10 +22,10 @@
 
 (define_expand "@atomic_compare_and_swap"
   [(match_operand:SI 0 "register_operand" "")  ;; bool out
-   (match_operand:ALLI 1 "register_operand" "");; val 
out
-   (match_operand:ALLI 2 "aarch64_sync_memory_operand" "") ;; memory
-   (match_operand:ALLI 3 "nonmemory_operand" "")   ;; expected
-   (match_operand:ALLI 4 "aarch64_reg_or_zero" "") ;; desired
+   (match_operand:ALLI_TI 1 "register_operand" "") ;;

[PATCH, AArch64, v3 1/6] aarch64: Extend %R for integer registers

2018-11-01 Thread Richard Henderson
From: Richard Henderson 

* config/aarch64/aarch64.c (aarch64_print_operand): Allow integer
registers with %R.
---
 gcc/config/aarch64/aarch64.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index b44ee40115d..930f27d9bac 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -7102,7 +7102,7 @@ sizetochar (int size)
  'S/T/U/V':Print a FP/SIMD register name for a register 
list.
The register printed is the FP/SIMD register name
of X + 0/1/2/3 for S/T/U/V.
- 'R':  Print a scalar FP/SIMD register name + 1.
+ 'R':  Print a scalar Integer/FP/SIMD register name + 1.
  'X':  Print bottom 16 bits of integer constant in hex.
  'w/x':Print a general register name or the zero register
(32-bit or 64-bit).
@@ -7294,12 +7294,13 @@ aarch64_print_operand (FILE *f, rtx x, int code)
   break;
 
 case 'R':
-  if (!REG_P (x) || !FP_REGNUM_P (REGNO (x)))
-   {
- output_operand_lossage ("incompatible floating point / vector 
register operand for '%%%c'", code);
- return;
-   }
-  asm_fprintf (f, "q%d", REGNO (x) - V0_REGNUM + 1);
+  if (REG_P (x) && FP_REGNUM_P (REGNO (x)))
+   asm_fprintf (f, "q%d", REGNO (x) - V0_REGNUM + 1);
+  else if (REG_P (x) && GP_REGNUM_P (REGNO (x)))
+   asm_fprintf (f, "x%d", REGNO (x) - R0_REGNUM + 1);
+  else
+   output_operand_lossage ("incompatible register operand for '%%%c'",
+   code);
   break;
 
 case 'X':
-- 
2.17.2



[PATCH, AArch64, v3 0/6] LSE atomics out-of-line

2018-11-01 Thread Richard Henderson
From: Richard Henderson 

Changes since v2:
  * Committed half of the patch set.
  * Split inline TImode support from out-of-line patches.
  * Removed the ST out-of-line functions, to match inline.
  * Moved the out-of-line functions to assembly.

What I have not done, but is now a possibility, is to use a custom
calling convention for the out-of-line routines.  I now only clobber
2 (or 3, for TImode) temp regs and set a return value.


r~
  

Richard Henderson (6):
  aarch64: Extend %R for integer registers
  aarch64: Implement TImode compare-and-swap
  aarch64: Tidy aarch64_split_compare_and_swap
  aarch64: Add out-of-line functions for LSE atomics
  aarch64: Implement -matomic-ool
  Enable -matomic-ool by default

 gcc/config/aarch64/aarch64-protos.h   |  13 +
 gcc/common/config/aarch64/aarch64-common.c|   6 +-
 gcc/config/aarch64/aarch64.c  | 211 
 .../atomic-comp-swap-release-acquire.c|   2 +-
 .../gcc.target/aarch64/atomic-op-acq_rel.c|   2 +-
 .../gcc.target/aarch64/atomic-op-acquire.c|   2 +-
 .../gcc.target/aarch64/atomic-op-char.c   |   2 +-
 .../gcc.target/aarch64/atomic-op-consume.c|   2 +-
 .../gcc.target/aarch64/atomic-op-imm.c|   2 +-
 .../gcc.target/aarch64/atomic-op-int.c|   2 +-
 .../gcc.target/aarch64/atomic-op-long.c   |   2 +-
 .../gcc.target/aarch64/atomic-op-relaxed.c|   2 +-
 .../gcc.target/aarch64/atomic-op-release.c|   2 +-
 .../gcc.target/aarch64/atomic-op-seq_cst.c|   2 +-
 .../gcc.target/aarch64/atomic-op-short.c  |   2 +-
 .../aarch64/atomic_cmp_exchange_zero_reg_1.c  |   2 +-
 .../atomic_cmp_exchange_zero_strong_1.c   |   2 +-
 .../gcc.target/aarch64/sync-comp-swap.c   |   2 +-
 .../gcc.target/aarch64/sync-op-acquire.c  |   2 +-
 .../gcc.target/aarch64/sync-op-full.c |   2 +-
 libgcc/config/aarch64/lse-init.c  |  45 
 gcc/config/aarch64/aarch64.opt|   4 +
 gcc/config/aarch64/atomics.md | 185 +-
 gcc/config/aarch64/iterators.md   |   3 +
 gcc/doc/invoke.texi   |  14 +-
 libgcc/config.host|   4 +
 libgcc/config/aarch64/lse.S   | 238 ++
 libgcc/config/aarch64/t-lse   |  44 
 28 files changed, 717 insertions(+), 84 deletions(-)
 create mode 100644 libgcc/config/aarch64/lse-init.c
 create mode 100644 libgcc/config/aarch64/lse.S
 create mode 100644 libgcc/config/aarch64/t-lse

-- 
2.17.2



Re: [wwwdocs] readings.html - add OpenRISC links

2018-11-01 Thread Segher Boessenkool
On Fri, Nov 02, 2018 at 06:20:56AM +0900, Stafford Horne wrote:
> As we were getting ready for OpenRISC gcc port upstreaming Segher pointed out
> that we should be updating this.
> 
> I don't think have CVS write access (only git binutils-gdb), can someone help 
> to
> review and commit if OK?

I committed this for you (as trivial and obvious).  Thanks!


Segher


[wwwdocs] readings.html - add OpenRISC links

2018-11-01 Thread Stafford Horne
Hello,

As we were getting ready for OpenRISC gcc port upstreaming Segher pointed out
that we should be updating this.

I don't think have CVS write access (only git binutils-gdb), can someone help to
review and commit if OK?

-Stafford

Index: readings.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/readings.html,v
retrieving revision 1.305
diff -u -r1.305 readings.html
--- readings.html   6 Oct 2018 17:36:29 -   1.305
+++ readings.html   1 Nov 2018 21:16:24 -
@@ -233,7 +233,13 @@
   Manufacturer: Intel (formerly Altera)
   https://www.intel.com/content/www/us/en/programmable/products/processors/support.html";>Nios
 II Processor Documentation
  
- 
+
+ OpenRISC
+  Manufacturer: Many (community built architecture)
+  https://openrisc.io";>OpenRISC Project
+  https://openrisc.io/architecture";>Architecture 
Specification
+ 
+
  pa
   Manufacturer: HP
   PA-RISC is preferred over the older HPPA acronym


Re: [PATCH, testsuite] add "inf" target attribute

2018-11-01 Thread Paul Koning



> On Nov 1, 2018, at 4:52 PM, Joseph Myers  wrote:
> 
> On Thu, 1 Nov 2018, Paul Koning wrote:
> 
>> +@item inf
>> +Target supports floating point infinite (@code{inf}).
>> @end table
> 
> Do you mean supports infinity for type double?  (That's what the 
> implementation does.)  Supporting it for double is not the same as 
> supporting it for float (SPU supports it for double but not float, hence 
> various such tests, which require infinities or NaNs (or other IEEE 
> features SPU doesn't have) for float, being disabled for SPU).)

Yes, I do mean for double.  I suppose I should say that.

I noticed SPU avoids using __builtin_inff by conditional compile.  I thought of 
adding an "inff" flag also.  The reason I didn't is that my target does not 
need that, so I would end up with a new feature that would only be applied on 
targets I do not know.

paul




Re: [PATCH, testsuite] add "inf" target attribute

2018-11-01 Thread Joseph Myers
On Thu, 1 Nov 2018, Paul Koning wrote:

> +@item inf
> +Target supports floating point infinite (@code{inf}).
>  @end table

Do you mean supports infinity for type double?  (That's what the 
implementation does.)  Supporting it for double is not the same as 
supporting it for float (SPU supports it for double but not float, hence 
various such tests, which require infinities or NaNs (or other IEEE 
features SPU doesn't have) for float, being disabled for SPU).)

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [PATCH 2/2 v3][IRA,LRA] Fix PR86939, IRA incorrectly creates an interference between a pseudo register and a hard register

2018-11-01 Thread Segher Boessenkool
Hi Renlin,

On Thu, Nov 01, 2018 at 06:50:22PM +, Renlin Li wrote:
> I got the following dump from the test case.
> 
> x1 is an early clobber operand in the inline assembly statement,
> r92 should conflict with x1?

Yes, I think so.  Or LRA should not pick something that was already a
hard register to spill (this should work without the earlyclobbers, too...
In this testcase that works anyhow, but that seems to be by accident).


Segher


Re: C++ PATCH to Implement P0846R0, ADL and function templates [v3]

2018-11-01 Thread Jason Merrill
On Thu, Nov 1, 2018 at 3:36 PM Marek Polacek  wrote:
> On Thu, Nov 01, 2018 at 12:15:48PM -0400, Jason Merrill wrote:
> > On 10/31/18 6:45 PM, Marek Polacek wrote:
> > > On Mon, Oct 29, 2018 at 05:59:13PM -0400, Jason Merrill wrote:
> > > > On 10/28/18 3:56 PM, Marek Polacek wrote:
> > > > > This patch implements P0846R0: ADL and Function Templates that are 
> > > > > not Visible
> > > > > 
> > > > > whereby a name for which a normal lookup produces either no result or 
> > > > > finds one
> > > > > or more functions and that is followed by a "<" would be treated as 
> > > > > if a function
> > > > > template name had been found and would cause ADL to be performed.  
> > > > > Thus e.g.
> > > > >
> > > > > namespace N {
> > > > > struct S { };
> > > > > template void f(S);
> > > > > }
> > > > >
> > > > > void
> > > > > bar (N::S s)
> > > > > {
> > > > > f<3>(s);
> > > > > }
> > > > >
> > > > > will now compile; ADL will find N::f.  The gist of the approach I 
> > > > > took is in
> > > > > cp_parser_template_name and setting TEMPLATE_ID_TRY_ADL_P.
> > > >
> > > > Why do you need that flag?  Can't you tell from the first operand of the
> > > > TEMPLATE_ID_EXPR whether it's suitable?
> > >
> > > I needed to distinguish between the two kinds of identifiers
> > > cp_parser_template_name can return.  But I found out I can (ab)use
> > > IDENTIFIER_BINDING for that.  If it's empty then name lookup didn't find
> > > anything (push_binding wasn't called for such an id), so we should try 
> > > ADL.
> > > Otherwise it's a dependent name and we need to wait for instantiation.
> > >
> > > > > There's something I'm not clear on; the proposal talks about an
> > > > > unqualified-id followed by a <, which is also the case for
> > > > >
> > > > > a.foo < 1;
> > > > >
> > > > > which is "postfix-expression . unqualified-id <", but treating "foo" 
> > > > > as a
> > > > > template name would break valid programs.  I don't think this 
> > > > > proposal should
> > > > > be in effect for class member accesses, so I've disabled it by using 
> > > > > scoped_p
> > > > > below.  See fn-template8.C for a complete testcase for this scenario.
> > > >
> > > > Agreed; ADL doesn't apply to class member access, so it shouldn't apply
> > > > here.  Sent mail to the core reflector.
> > >
> > > Great, thanks for that.
> > >
> > > > > @@ -7165,7 +7165,9 @@ cp_parser_postfix_expression (cp_parser 
> > > > > *parser, bool address_p, bool cast_p,
> > > > > if (idk == CP_ID_KIND_UNQUALIFIED
> > > > > || idk == CP_ID_KIND_TEMPLATE_ID)
> > > > >   {
> > > > > -   if (identifier_p (postfix_expression))
> > > > > +   if (identifier_p (postfix_expression)
> > > > > +   || (TREE_CODE (postfix_expression) == 
> > > > > TEMPLATE_ID_EXPR
> > > > > +   && TEMPLATE_ID_TRY_ADL_P 
> > > > > (postfix_expression)))
> > > >
> > > > Here I think you can check whether the first operand is an identifier.
> > >
> > > Changed, along with checking for IDENTIFIER_BINDING.  E.g. this is a test 
> > > that
> > > would fail if we tried ADL for a template-id with any identifier:
> > >
> > >template  struct X {
> > >  X() { fn<>(0); }
> > >  template  void fn();
> > >};
> > >
> > > here we need to perform two-stage lookup.
> >
> > I don't see why; when we look up fn we find the member template, and we
> > should remember that.  I think this code:
> >
> > >   /* If DECL is dependent, and refers to a function, then just return
> > > its name; we will look it up again during template instantiation.  */
> > >   if (DECL_FUNCTION_TEMPLATE_P (decl) || !DECL_P (decl))
> > > {
> > >   tree scope = ovl_scope (decl);
> > >   if (TYPE_P (scope) && dependent_type_p (scope))
> > > return identifier;
> > > }
> >
> > should go so that returning an identifier can consistently mean nothing
> > found.
>
> Woo!  That's nice that I can do that: it simplifies other stuff.  Removing
> this hunk triggered an assert in tsubst_copy (just one testcase), but when
> I moved it, everything seemed to work well.
>
> So this is a version which doesn't use IDENTIFIER_BINDING at all.  Thanks,
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>
> 2018-11-01  Marek Polacek  
>
> Implement P0846R0, ADL and function templates.
> * decl.c (grokfndecl): Allow FUNCTION_DECL in assert.
> * lex.c (unqualified_fn_lookup_error): Handle TEMPLATE_ID_EXPR.
> * parser.c (cp_parser_postfix_expression): Do ADL for a template-name.
> (cp_parser_template_id): Give errors if parsing the template argument
> list didn't go well.  Allow FUNCTION_DECL in assert.
> (cp_parser_template_name): Consider a name to refer to a template if
> it is an unqualified-id followed by a <.  Don't return the identifier
> if the decl is a functi

Re: Update GCC to autoconf 2.69, automake 1.15.1

2018-11-01 Thread Janne Blomqvist
On Wed, Oct 31, 2018 at 7:05 PM Joseph Myers 
wrote:

> I've committed this revised patch version


Thank you for taking on this work.


> As noted, my expectation is that libgfortran, libgo, libgomp,
> liboffloadmic, libsanitizer, libphobos maintainers will deal with
> moving those directories to subdir-objects, with any consequent fixes
> needed, to eliminate the automake warnings about subdirectory sources
> without using subdir-objects - and I don't know whether use of ../ in
> source paths in some directories complicates things (if subdir-objects
> would result in attempts to put resulting objects in ../, outside the
> normal build directory for the library) or not.
>

Turned out that for libgfortran, at least, this doesn't seem trivial.
Problem is that we have some of the sources listed relative to $(srcdir) in
Makefile.am, which breaks when enabling subdir-objects. But we can't remove
the $(srcdir) either, becase these sources in question are generated from
m4 sources when --enable-maintainer-mode is enabled, and $(srcdir) is thus
needed so that the generated files will correctly end up in in the source
tree and not the build tree. Gah!

I filed https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87856 to keep track of
this.

-- 
Janne Blomqvist


Re: C++ PATCH to Implement P0846R0, ADL and function templates [v3]

2018-11-01 Thread Marek Polacek
On Thu, Nov 01, 2018 at 03:36:04PM -0400, Marek Polacek wrote:
> this hunk triggered an assert in tsubst_copy (just one testcase), but when
> I moved it, everything seemed to work well.

*removed*


Re: C++ PATCH to Implement P0846R0, ADL and function templates [v3]

2018-11-01 Thread Marek Polacek
On Thu, Nov 01, 2018 at 12:15:48PM -0400, Jason Merrill wrote:
> On 10/31/18 6:45 PM, Marek Polacek wrote:
> > On Mon, Oct 29, 2018 at 05:59:13PM -0400, Jason Merrill wrote:
> > > On 10/28/18 3:56 PM, Marek Polacek wrote:
> > > > This patch implements P0846R0: ADL and Function Templates that are not 
> > > > Visible
> > > > 
> > > > whereby a name for which a normal lookup produces either no result or 
> > > > finds one
> > > > or more functions and that is followed by a "<" would be treated as if 
> > > > a function
> > > > template name had been found and would cause ADL to be performed.  Thus 
> > > > e.g.
> > > > 
> > > > namespace N {
> > > > struct S { };
> > > > template void f(S);
> > > > }
> > > > 
> > > > void
> > > > bar (N::S s)
> > > > {
> > > > f<3>(s);
> > > > }
> > > > 
> > > > will now compile; ADL will find N::f.  The gist of the approach I took 
> > > > is in
> > > > cp_parser_template_name and setting TEMPLATE_ID_TRY_ADL_P.
> > > 
> > > Why do you need that flag?  Can't you tell from the first operand of the
> > > TEMPLATE_ID_EXPR whether it's suitable?
> > 
> > I needed to distinguish between the two kinds of identifiers
> > cp_parser_template_name can return.  But I found out I can (ab)use
> > IDENTIFIER_BINDING for that.  If it's empty then name lookup didn't find
> > anything (push_binding wasn't called for such an id), so we should try ADL.
> > Otherwise it's a dependent name and we need to wait for instantiation.
> > 
> > > > There's something I'm not clear on; the proposal talks about an
> > > > unqualified-id followed by a <, which is also the case for
> > > > 
> > > > a.foo < 1;
> > > > 
> > > > which is "postfix-expression . unqualified-id <", but treating "foo" as 
> > > > a
> > > > template name would break valid programs.  I don't think this proposal 
> > > > should
> > > > be in effect for class member accesses, so I've disabled it by using 
> > > > scoped_p
> > > > below.  See fn-template8.C for a complete testcase for this scenario.
> > > 
> > > Agreed; ADL doesn't apply to class member access, so it shouldn't apply
> > > here.  Sent mail to the core reflector.
> > 
> > Great, thanks for that.
> > 
> > > > @@ -7165,7 +7165,9 @@ cp_parser_postfix_expression (cp_parser *parser, 
> > > > bool address_p, bool cast_p,
> > > > if (idk == CP_ID_KIND_UNQUALIFIED
> > > > || idk == CP_ID_KIND_TEMPLATE_ID)
> > > >   {
> > > > -   if (identifier_p (postfix_expression))
> > > > +   if (identifier_p (postfix_expression)
> > > > +   || (TREE_CODE (postfix_expression) == 
> > > > TEMPLATE_ID_EXPR
> > > > +   && TEMPLATE_ID_TRY_ADL_P (postfix_expression)))
> > > 
> > > Here I think you can check whether the first operand is an identifier.
> > 
> > Changed, along with checking for IDENTIFIER_BINDING.  E.g. this is a test 
> > that
> > would fail if we tried ADL for a template-id with any identifier:
> > 
> >template  struct X {
> >  X() { fn<>(0); }
> >  template  void fn();
> >};
> > 
> > here we need to perform two-stage lookup.
> 
> I don't see why; when we look up fn we find the member template, and we
> should remember that.  I think this code:
> 
> >   /* If DECL is dependent, and refers to a function, then just return
> > its name; we will look it up again during template instantiation.  */
> >   if (DECL_FUNCTION_TEMPLATE_P (decl) || !DECL_P (decl))
> > {
> >   tree scope = ovl_scope (decl);
> >   if (TYPE_P (scope) && dependent_type_p (scope))
> > return identifier;
> > }
> 
> should go so that returning an identifier can consistently mean nothing
> found.

Woo!  That's nice that I can do that: it simplifies other stuff.  Removing
this hunk triggered an assert in tsubst_copy (just one testcase), but when
I moved it, everything seemed to work well.

So this is a version which doesn't use IDENTIFIER_BINDING at all.  Thanks,

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2018-11-01  Marek Polacek  

Implement P0846R0, ADL and function templates.
* decl.c (grokfndecl): Allow FUNCTION_DECL in assert.
* lex.c (unqualified_fn_lookup_error): Handle TEMPLATE_ID_EXPR.
* parser.c (cp_parser_postfix_expression): Do ADL for a template-name.
(cp_parser_template_id): Give errors if parsing the template argument
list didn't go well.  Allow FUNCTION_DECL in assert.
(cp_parser_template_name): Consider a name to refer to a template if
it is an unqualified-id followed by a <.  Don't return the identifier
if the decl is a function and dependent.
* pt.c (tsubst_copy) : Remove assert.

* g++.dg/addr_builtin-1.C: Adjust dg-error.
* g++.dg/cpp2a/fn-template1.C: New test.
* g++.dg/cpp2a/fn-template10.C: New test.
* g++.dg/cpp2a/fn-template11.C: New test.
* 

[PATCH, testsuite] add "inf" target attribute

2018-11-01 Thread Paul Koning
A number of test cases fail on pdp11 because they use the "inf" float value 
which does not exist on that target (nor on VAX).  Rainer Orth and Joseph Myers 
suggested adding a new effective-target keyword to check for this, and require 
it for tests that have that dependency.

The attached patch implements this.  Ok for trunk?

paul

ChangeLog:

2018-11-01  Paul Koning  

* doc/sourcebuild.texi (target attributes): Document new "inf"
effective target keyword.

Index: doc/sourcebuild.texi
===
--- doc/sourcebuild.texi(revision 265728)
+++ doc/sourcebuild.texi(working copy)
@@ -1393,8 +1393,10 @@ for any options added with @code{dg-add-options}.
 Target has runtime support for any options added with
 @code{dg-add-options} for any @code{_Float@var{n}} or
 @code{_Float@var{n}x} type.
+
+@item inf
+Target supports floating point infinite (@code{inf}).
 @end table
-
 @subsubsection Fortran-specific attributes
 
 @table @code


testsuite/ChangeLog:

2018-11-01  Paul Koning  

* lib/target-supports.exp: Add check for "inf" effective target
keyword.
* gcc.dg/builtins-44.c: Skip if no infinite support.
* gcc.dg/builtins-45.c: Ditto.
* gcc.dg/torture/builtin-complex-1.c: Ditto.
* gcc.dg/torture/builtin-cproj-1.c: Ditto.
* gcc.dg/torture/builtin-frexp-1.c: Ditto.
* gcc.dg/torture/builtin-ldexp-1.c: Ditto.
* gcc.dg/torture/builtin-logb-1.c: Ditto.
* gcc.dg/torture/builtin-math-2.c: Ditto.
* gcc.dg/torture/builtin-math-5.c: Ditto.
* gcc.dg/torture/builtin-math-7.c: Ditto.
* gcc.dg/torture/builtin-modf-1.c: Ditto.
* gcc.dg/torture/type-generic-1.c: Ditto.


Index: lib/target-supports.exp
===
--- lib/target-supports.exp (revision 265728)
+++ lib/target-supports.exp (working copy)
@@ -8933,3 +8933,10 @@ proc check_effective_target_cet { } {
}
 } "-O2" ]
 }
+
+# Return 1 if target supports floating point "infinite"
+proc check_effective_target_inf { } {
+return [check_no_compiler_messages supports_inf assembly {
+const double pinf = __builtin_inf ();
+}]
+}
Index: gcc.dg/builtins-44.c
===
--- gcc.dg/builtins-44.c(revision 265728)
+++ gcc.dg/builtins-44.c(working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-require-effective-target inf } */
 /* { dg-options "-O1 -fno-trapping-math -fno-finite-math-only 
-fdump-tree-optimized" } */
   
 extern void f(int);
Index: gcc.dg/builtins-45.c
===
--- gcc.dg/builtins-45.c(revision 265728)
+++ gcc.dg/builtins-45.c(working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-require-effective-target inf } */
 /* { dg-options "-O1 -fno-trapping-math -fno-finite-math-only 
-fdump-tree-optimized" } */
   
 extern void f(int);
Index: gcc.dg/torture/builtin-complex-1.c
===
--- gcc.dg/torture/builtin-complex-1.c  (revision 265728)
+++ gcc.dg/torture/builtin-complex-1.c  (working copy)
@@ -1,6 +1,7 @@
 /* Test __builtin_complex semantics.  */
 /* { dg-do run } */
 /* { dg-options "-std=c11 -pedantic-errors" } */
+/* { dg-require-effective-target inf } */
 /* { dg-add-options ieee } */
 
 extern void exit (int);
Index: gcc.dg/torture/builtin-cproj-1.c
===
--- gcc.dg/torture/builtin-cproj-1.c(revision 265728)
+++ gcc.dg/torture/builtin-cproj-1.c(working copy)
@@ -7,6 +7,7 @@
 
 /* { dg-do link } */
 /* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
+/* { dg-require-effective-target inf } */
 /* { dg-add-options ieee } */
 
 /* All references to link_error should go away at compile-time.  The
Index: gcc.dg/torture/builtin-frexp-1.c
===
--- gcc.dg/torture/builtin-frexp-1.c(revision 265728)
+++ gcc.dg/torture/builtin-frexp-1.c(working copy)
@@ -9,6 +9,7 @@
 /* { dg-options "-fno-finite-math-only" { target sh*-*-* } } */
 /* In order to fold algebraic exprs below, targets with "composite"
floating point formats need -funsafe-math-optimizations.  */
+/* { dg-require-effective-target inf } */
 /* { dg-options "-funsafe-math-optimizations" { target powerpc*-*-* } } */
 
 extern void link_error(int);
Index: gcc.dg/torture/builtin-ldexp-1.c
===
--- gcc.dg/torture/builtin-ldexp-1.c(revision 265728)
+++ gcc.dg/torture/builtin-ldexp-1.c(working copy)
@@ -7,6 +7,7 @@
 
 /* { dg-do link } */
 /* { dg-options "-fno-finite-math-only" { target sh*-*-* } } */
+/* { dg-require-effective-target inf } */
 /* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
 

Re: [patch, fortran] Fux PR 87782

2018-11-01 Thread Janne Blomqvist
On Thu, Nov 1, 2018 at 9:13 PM Thomas Koenig  wrote:

> Hello world,
>
> the attached patch fixes the PR by not trying to determine the length
> of the base symbol when there is a substring with a length which
> is not constant.  This might make the length of temporary strings
> generated by the front end optimization pass shorter, while inserting
> an additional call to determine length of the substring.
>
> No test case because the failure was only exposed by an instrumented
> compiler.
>
> Regression-tested. OK for trunk?
>

Ok, thanks!


-- 
Janne Blomqvist


[patch, fortran] Fux PR 87782

2018-11-01 Thread Thomas Koenig

Hello world,

the attached patch fixes the PR by not trying to determine the length
of the base symbol when there is a substring with a length which
is not constant.  This might make the length of temporary strings
generated by the front end optimization pass shorter, while inserting
an additional call to determine length of the substring.

No test case because the failure was only exposed by an instrumented
compiler.

Regression-tested. OK for trunk?

Regards

Thomas

2018-11-01  Thomas Koenig  

PR fortran/87782
* frontend-passes.c (constant_string_length): If there is a
substring with a length which cannot be reduced to a constant,
return NULL.
Index: frontend-passes.c
===
--- frontend-passes.c	(Revision 265722)
+++ frontend-passes.c	(Arbeitskopie)
@@ -638,23 +638,27 @@ constant_string_length (gfc_expr *e)
 	return gfc_copy_expr(length);
 }
 
-  /* Return length of substring, if constant. */
+  /* See if there is a substring. If it has a constant length, return
+ that and NULL otherwise.  */
   for (ref = e->ref; ref; ref = ref->next)
 {
-  if (ref->type == REF_SUBSTRING
-	  && gfc_dep_difference (ref->u.ss.end, ref->u.ss.start, &value))
+  if (ref->type == REF_SUBSTRING)
 	{
-	  res = gfc_get_constant_expr (BT_INTEGER, gfc_charlen_int_kind,
-   &e->where);
+	  if (gfc_dep_difference (ref->u.ss.end, ref->u.ss.start, &value))
+	{
+	  res = gfc_get_constant_expr (BT_INTEGER, gfc_charlen_int_kind,
+	   &e->where);
 
-	  mpz_add_ui (res->value.integer, value, 1);
-	  mpz_clear (value);
-	  return res;
+	  mpz_add_ui (res->value.integer, value, 1);
+	  mpz_clear (value);
+	  return res;
+	}
+	  else
+	return NULL;
 	}
 }
 
   /* Return length of char symbol, if constant.  */
-
   if (e->symtree && e->symtree->n.sym->ts.u.cl
   && e->symtree->n.sym->ts.u.cl->length
   && e->symtree->n.sym->ts.u.cl->length->expr_type == EXPR_CONSTANT)


[PATCH, testsuite] ignore some "conflicting types for built-in" messages

2018-11-01 Thread Paul Koning
A number of test cases contain declarations like:
  void *memcpy();
which currently are silently accepted on most platforms but not on all; pdp11 
(and possibly some others) generate a "conflicting types for built-in function" 
warning.

It was suggested to prune those messages because the test cases where these 
occur are not looking for the message but are testing some other issue, so the 
message is not relevant.  The attached patch adds dg-prune-output directives to 
do so.

Ok for trunk?

paul

ChangeLog:

2018-11-01  Paul Koning  

* gcc.dg/Walloca-16.c: Ignore conflicting types for built-in
warnings.
* gcc.dg/Wrestrict-4.c: Ditto.
* gcc.dg/Wrestrict-5.c: Ditto.
* gcc.dg/pr83463.c: Ditto.
* gcc.dg/torture/pr55890-2.c: Ditto.
* gcc.dg/torture/pr55890-3.c: Ditto.
* gcc.dg/torture/pr71816.c: Ditto.

Index: gcc.dg/Walloca-16.c
===
--- gcc.dg/Walloca-16.c (revision 265727)
+++ gcc.dg/Walloca-16.c (working copy)
@@ -1,5 +1,6 @@
 /* PR tree-optimization/84224 */
 /* { dg-do compile } */
+/* { dg-prune-output "conflicting types for built-in" } */
 /* { dg-options "-O0 -Walloca" } */
 
 void *alloca ();
Index: gcc.dg/Wrestrict-4.c
===
--- gcc.dg/Wrestrict-4.c(revision 265727)
+++ gcc.dg/Wrestrict-4.c(working copy)
@@ -3,6 +3,7 @@
Test to verify that invalid calls to built-in functions declared
without a prototype don't cause an ICE.
{ dg-do compile }
+   { dg-prune-output "conflicting types for built-in" }
{ dg-options "-O2 -Warray-bounds -Wrestrict" } */
 
 void* memcpy ();
Index: gcc.dg/Wrestrict-5.c
===
--- gcc.dg/Wrestrict-5.c(revision 265727)
+++ gcc.dg/Wrestrict-5.c(working copy)
@@ -2,6 +2,7 @@
functions declared with no prototype are checked for overlap, and that
invalid calls are ignored.
   { dg-do compile }
+  { dg-prune-output "conflicting types for built-in" }
   { dg-options "-O2 -Wrestrict" }  */
 
 typedef __SIZE_TYPE__ size_t;
Index: gcc.dg/pr83463.c
===
--- gcc.dg/pr83463.c(revision 265727)
+++ gcc.dg/pr83463.c(working copy)
@@ -1,5 +1,6 @@
 /* PR middle-end/83463 */
 /* { dg-do compile } */
+/* { dg-prune-output "conflicting types for built-in" } */
 /* { dg-options "-O2 -Wrestrict -Wno-pointer-to-int-cast" } */
 
 int *a;
Index: gcc.dg/torture/pr55890-2.c
===
--- gcc.dg/torture/pr55890-2.c  (revision 265727)
+++ gcc.dg/torture/pr55890-2.c  (working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-prune-output "conflicting types for built-in" } */
 
 extern void *memcpy();
 int main() { memcpy(); }
Index: gcc.dg/torture/pr55890-3.c
===
--- gcc.dg/torture/pr55890-3.c  (revision 265727)
+++ gcc.dg/torture/pr55890-3.c  (working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-prune-output "conflicting types for built-in" } */
 
 void *memmove ();
 
Index: gcc.dg/torture/pr71816.c
===
--- gcc.dg/torture/pr71816.c(revision 265727)
+++ gcc.dg/torture/pr71816.c(working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-prune-output "conflicting types for built-in" } */
 
 void *ext2fs_resize_mem_p;
 struct ext2_icount_el {



[PATCH, testsuite] test case fixes for pdp11

2018-11-01 Thread Paul Koning
This patch fixes a number of test case failures on pdp11.  Some are too large 
for the address space, some have dependencies on the float format that don't 
match the DEC format, some add pdp11 to the targets that expect particular 
compiler messages.

Committed.

paul

ChangeLog:

2018-11-01  Paul Koning  

* gcc.c-torture/execute/20010904-1.c: Align 2 if pdp11.
* gcc.c-torture/execute/20010904-2.c: Ditto.
* c-c++-common/builtin-arith-overflow-2.c: Skip if pdp11.
* gcc.dg/Walloc-size-larger-than-4.c: Ditto.
* gcc.dg/Walloc-size-larger-than-5.c: Ditto.
* gcc.dg/Walloc-size-larger-than-6.c: Ditto.
* gcc.dg/Walloc-size-larger-than-7.c: Ditto.
* gcc.dg/Walloca-14.c: Ditto.
* gcc.dg/Wlarger-than3.c: Ditto.
* gcc.dg/compat/pr83487-1_y.c: Ditto.
* gcc.dg/compat/struct-by-value-2_x.c: Ditto.
* gcc.dg/compat/struct-by-value-3_x.c: Ditto.
* gcc.dg/compat/struct-by-value-4_x.c: Ditto.
* gcc.dg/compat/struct-by-value-5b_x.c: Ditto.
* gcc.dg/compat/struct-by-value-6b_x.c: Ditto.
* gcc.dg/compat/struct-by-value-7b_x.c: Ditto.
* gcc.dg/compat/struct-by-value-8_x.c: Ditto.
* gcc.dg/compat/struct-by-value-9_x.c: Ditto.
* gcc.dg/compat/struct-by-value-10_x.c: Ditto.
* gcc.dg/compat/struct-by-value-11_x.c: Ditto.
* gcc.dg/compat/struct-by-value-12_x.c: Ditto.
* gcc.dg/compat/struct-by-value-13_x.c: Ditto.
* gcc.dg/compat/struct-by-value-14_x.c: Ditto.
* gcc.dg/compat/struct-by-value-15_x.c: Ditto.
* gcc.dg/compat/struct-by-value-16_x.c: Ditto.
* gcc.dg/compat/struct-by-value-17_x.c: Ditto.
* gcc.dg/compat/struct-by-value-18_x.c: Ditto.
* gcc.dg/compat/struct-by-value-22_x.c: Ditto.
* gcc.dg/compat/struct-return-2_x.c: Ditto.
* gcc.dg/falign-labels-1.c: Ditto.
* gcc.dg/long_branch.c: Ditto.
* gcc.dg/nextafter-1.c: Ditto.
* gcc.dg/pr35045.c: Ditto.
* gcc.dg/pr48616.c: Ditto.
* gcc.dg/pr84100.c: Ditto.
* gcc.dg/tree-ssa/builtin-sprintf-9.c: Ditto.
* gcc.dg/tree-ssa/builtin-sprintf-warn-10.c: Ditto.
* gcc.dg/tree-ssa/builtin-sprintf.c: Ditto.
* gcc.dg/Wattributes-10.c: Expect error if pdp11.
* gcc.dg/attr-alloc_size-11.c: Don't XFAIL if pdp11.
* gcc.dg/builtin-inf-1.c: Add pdp11 to warnings about INF.
* gcc.dg/builtins-1.c: Ditto.

Index: gcc.c-torture/execute/20010904-1.c
===
--- gcc.c-torture/execute/20010904-1.c  (revision 265727)
+++ gcc.c-torture/execute/20010904-1.c  (working copy)
@@ -1,4 +1,12 @@
-typedef struct x { int a; int b; } __attribute__((aligned(32))) X;
+/* If some target has a Max alignment less than 32, please create
+   a #ifdef around the alignment and add your alignment.  */
+#ifdef __pdp11__
+#define alignment 2
+#else
+#define alignment 32
+#endif
+
+typedef struct x { int a; int b; } __attribute__((aligned(alignment))) X;
 typedef struct y { X x[32]; int c; } Y;
 
 Y y[2];
Index: gcc.c-torture/execute/20010904-2.c
===
--- gcc.c-torture/execute/20010904-2.c  (revision 265727)
+++ gcc.c-torture/execute/20010904-2.c  (working copy)
@@ -1,4 +1,12 @@
-typedef struct x { int a; int b; } __attribute__((aligned(32))) X;
+/* If some target has a Max alignment less than 32, please create
+   a #ifdef around the alignment and add your alignment.  */
+#ifdef __pdp11__
+#define alignment 2
+#else
+#define alignment 32
+#endif
+
+typedef struct x { int a; int b; } __attribute__((aligned(aligned))) X;
 typedef struct y { X x; X y[31]; int c; } Y;
 
 Y y[2];
Index: c-c++-common/builtin-arith-overflow-2.c
===
--- c-c++-common/builtin-arith-overflow-2.c (revision 265727)
+++ c-c++-common/builtin-arith-overflow-2.c (working copy)
@@ -1,7 +1,7 @@
 /* PR c/68120 - can't easily deal with integer overflow at compile time */
 /* { dg-do run } */
 /* { dg-additional-options "-Wno-long-long" } */
-/* { dg-skip-if "Program too big" { "avr-*-*" } } */
+/* { dg-skip-if "Program too big" { "avr-*-* pdp11*-*-*" } } */
 
 #define SCHAR_MAX__SCHAR_MAX__
 #define SHRT_MAX __SHRT_MAX__
Index: gcc.dg/Walloc-size-larger-than-4.c
===
--- gcc.dg/Walloc-size-larger-than-4.c  (revision 265727)
+++ gcc.dg/Walloc-size-larger-than-4.c  (working copy)
@@ -1,5 +1,6 @@
 /* PR middle-end/82063 - issues with arguments enabled by -Wall
{ dg-do compile }
+   { dg-skip-if "small address space" { "pdp11-*-*" } }
{ dg-options "-O -Walloc-size-larger-than=1MiB -ftrack-macro-expansion=0" } 
*/
 
 void sink (void*);
Index: gcc.dg/Walloc-size-larger-than-5.c
===
--- gcc.dg/Walloc-size

Re: [PATCH 2/2 v3][IRA,LRA] Fix PR86939, IRA incorrectly creates an interference between a pseudo register and a hard register

2018-11-01 Thread Renlin Li

Hi Peter,

Is there any update on this issues?
arm-none-linux-gnueabihf native toolchain has been mis-compiled for a while.

I got the following dump from the test case.

x1 is an early clobber operand in the inline assembly statement,
r92 should conflict with x1?

;; a0(r93,l0) conflicts: a1(r92,l0)
;; total conflict hard regs: 0-4 16 17 30
;; conflict hard regs: 0-4 16 17 30


;; a1(r92,l0) conflicts: a0(r93,l0)
;; total conflict hard regs: 0 2-4 16 17 30
;; conflict hard regs: 0 2-4 16 17 30

Dump from ira.

(insn 2 8 6 2 (set (reg/v:DI 92 [ arg ])
(reg:DI 97)) "test.c":3:1 47 {*movdi_aarch64}
 (expr_list:REG_DEAD (reg:DI 97)
(nil)))
(insn 7 6 9 2 (set (reg/v:DI 1 x1 [ x1 ])
(reg/v:DI 92 [ arg ])) "test.c":13:26 47 {*movdi_aarch64}
 (nil))
(insn 11 10 14 2 (set (reg/f:DI 93)
(const_int 0 [0])) "test.c":17:3 47 {*movdi_aarch64}
 (expr_list:REG_EQUIV (const_int 0 [0])
(nil)))
(insn 14 11 21 2 (parallel [
(set (reg/v:DI 0 x0 [ x0 ])
(asm_operands/v:DI ("  casp%0, %1, %3, %4, %2
eor %0, %0, %6
eor %1, %1, %7
orr %0, %0, %1
") ("=&r") 0 [
(reg/v:DI 2 x2 [ x2 ])
(reg/v:DI 3 x3 [ x3 ])
(reg/v:DI 4 x4 [ x4 ])
(reg/f:DI 93)
(reg/v:DI 92 [ arg ])
(reg/v:DI 0 x0 [ x0 ])
(reg/v:DI 1 x1 [ x1 ])
(mem:DI (reg/f:DI 93) [1 MEM[(long unsigned int *)0B]+0 
S8 A128])
]
 [
(asm_input:DI ("r") test.c:17)
(asm_input:DI ("r") test.c:17)
(asm_input:DI ("r") test.c:17)
(asm_input:DI ("r") test.c:17)
(asm_input:DI ("r") test.c:17)
(asm_input:DI ("0") test.c:17)
(asm_input:DI ("1") test.c:17)
(asm_input:DI ("Q") test.c:17)
]
 [] test.c:17))
(set (reg/v:DI 1 x1 [ x1 ])
(asm_operands/v:DI ("  casp%0, %1, %3, %4, %2
eor %0, %0, %6
eor %1, %1, %7
orr %0, %0, %1
") ("=&r") 1 [
(reg/v:DI 2 x2 [ x2 ])
(reg/v:DI 3 x3 [ x3 ])
(reg/v:DI 4 x4 [ x4 ])
(reg/f:DI 93)
(reg/v:DI 92 [ arg ])
(reg/v:DI 0 x0 [ x0 ])
(reg/v:DI 1 x1 [ x1 ])
(mem:DI (reg/f:DI 93) [1 MEM[(long unsigned int *)0B]+0 
S8 A128])
]
 [
(asm_input:DI ("r") test.c:17)
(asm_input:DI ("r") test.c:17)
(asm_input:DI ("r") test.c:17)
(asm_input:DI ("r") test.c:17)
(asm_input:DI ("r") test.c:17)
(asm_input:DI ("0") test.c:17)
(asm_input:DI ("1") test.c:17)
(asm_input:DI ("Q") test.c:17)
]
 [] test.c:17))
(set (mem:DI (reg/f:DI 93) [1 MEM[(long unsigned int *)0B]+0 S8 
A128])
(asm_operands/v:DI ("  casp%0, %1, %3, %4, %2
eor %0, %0, %6
eor %1, %1, %7
orr %0, %0, %1
") ("=Q") 2 [
(reg/v:DI 2 x2 [ x2 ])
(reg/v:DI 3 x3 [ x3 ])
(reg/v:DI 4 x4 [ x4 ])
(reg/f:DI 93)
(reg/v:DI 92 [ arg ])
(reg/v:DI 0 x0 [ x0 ])
(reg/v:DI 1 x1 [ x1 ])
(mem:DI (reg/f:DI 93) [1 MEM[(long unsigned int *)0B]+0 
S8 A128])
]
 [
(asm_input:DI ("r") test.c:17)
(asm_input:DI ("r") test.c:17)
(asm_input:DI ("r") test.c:17)
(asm_input:DI ("r") test.c:17)
(asm_input:DI ("r") test.c:17)
(asm_input:DI ("0") test.c:17)
(asm_input:DI ("1") test.c:17)
(asm_input:DI ("Q") test.c:17)
]
 [] test.c:17))
(clobber (reg:DI 30 x30))
(clobber (reg:DI 17 x17))
(clobber (reg:DI 16 x16))
]) "test.c":17:3 -1
 (expr_list:REG_DEAD (reg/f:DI 93)
(expr_list:REG_DEAD (reg/v:DI 92 [ arg ])
(expr_list:REG_DEAD (reg/v:DI 4 x4 [ x4 ])
(expr_list:REG_DEAD (reg/v:DI 3 x3 [ x3 ])
(expr_list:REG_DEAD (reg/v:DI 2 x2 [ x2 ])
(expr_list:REG_UNUSED (reg:DI 30 x30)
 

[PATCH] libgcc build fix for pdp11

2018-11-01 Thread Paul Koning
This fixes some test suite failures due to a missing arithmetic support routine.

Committed.

paul

ChangeLog:

2018-11-01  Paul Koning  

* config/pdp11/t-pdp11 (LIB2ADD): Add divmod.c.
(HOST_LIBGCC2_CFLAGS): Change to optimize for size.

Index: config/pdp11/t-pdp11
===
--- config/pdp11/t-pdp11(revision 265725)
+++ config/pdp11/t-pdp11(working copy)
@@ -1,4 +1,5 @@
-LIB2ADD = $(srcdir)/udivmod.c \
+LIB2ADD = $(srcdir)/divmod.c \
+ $(srcdir)/udivmod.c \
  $(srcdir)/udivmodsi4.c \
  $(srcdir)/udivhi3.c \
  $(srcdir)/udivmodhi4.c \
@@ -7,4 +8,5 @@
  $(srcdir)/memmove.c \
  $(srcdir)/memset.c
 
-HOST_LIBGCC2_CFLAGS += -O2
+# Small machine, optimize for size
+HOST_LIBGCC2_CFLAGS += -Os



Re: C++ PATCH to add test to cover case RANGE_FOR_STMT

2018-11-01 Thread Jason Merrill

On 11/1/18 2:06 PM, Marek Polacek wrote:

Ping.

On Thu, Oct 11, 2018 at 09:28:38PM -0400, Marek Polacek wrote:

Recently it came up that no test in the testsuite triggers the RANGE_FOR_STMT
case in potential_constant_expression_1.  I came up with this valid test that
tickles that codepath.

I can't use ({ }) instead of a lambda because the constexpr machinery doesn't
handle statement expressions; see default: in cxx_eval_constant_expression.

Tested on x86_64-linux, ok for trunk?

2018-10-11  Marek Polacek  

* g++.dg/cpp1z/constexpr-lambda22.C: New test,


OK, thanks.

Jason



Re: C++ PATCH to add test to cover case RANGE_FOR_STMT

2018-11-01 Thread Marek Polacek
Ping.

On Thu, Oct 11, 2018 at 09:28:38PM -0400, Marek Polacek wrote:
> Recently it came up that no test in the testsuite triggers the RANGE_FOR_STMT
> case in potential_constant_expression_1.  I came up with this valid test that
> tickles that codepath.
> 
> I can't use ({ }) instead of a lambda because the constexpr machinery doesn't
> handle statement expressions; see default: in cxx_eval_constant_expression.
> 
> Tested on x86_64-linux, ok for trunk?
> 
> 2018-10-11  Marek Polacek  
> 
>   * g++.dg/cpp1z/constexpr-lambda22.C: New test,
> 
> diff --git gcc/testsuite/g++.dg/cpp1z/constexpr-lambda22.C 
> gcc/testsuite/g++.dg/cpp1z/constexpr-lambda22.C
> index e69de29bb2d..8bb473431a5 100644
> --- gcc/testsuite/g++.dg/cpp1z/constexpr-lambda22.C
> +++ gcc/testsuite/g++.dg/cpp1z/constexpr-lambda22.C
> @@ -0,0 +1,20 @@
> +// { dg-do compile }
> +// { dg-options -std=c++17 }
> +
> +#define SA(X) static_assert((X),#X)
> +
> +template
> +constexpr int
> +foo ()
> +{
> +  constexpr int a[] = { 1, 2, 3, 4, 5 };
> +  int i = 0;
> +  auto j = [&] {
> +for (auto x : a)
> +  i++;
> +return i;
> +  }();
> +  return j;
> +}
> +
> +SA (foo() == 5);

Marek


Re: V2 [PATCH] i386: Use scalar operand in SF/DF/SI/DI vec_dup patterns

2018-11-01 Thread Uros Bizjak
On Tue, Oct 30, 2018 at 9:36 PM H.J. Lu  wrote:

> > Why not at the expand time? Rewrite vector constant as vec_duplicate
> > from memory and combine will do the stuff for you. We do have _bcst
> > instruction patterns.
> >
>
> Here is the updated patch to do that.  OK for trunk?

Looks mostly good, however IMO we should move the expansion out of
ix86_expand_args_builtin. We have an example of
ix86_expand_unop_vec_merge_builtin and VEC_MERGE type in
i386-builtin-types.def on how to handle special builtins.

Uros.

> Thanks.
>
>
> --
> H.J.


Re: [PATCH] x86: Update VFIXUPIMM* Intrinsics to align with the latest Intel SDM

2018-11-01 Thread Uros Bizjak
On Tue, Oct 30, 2018 at 10:12 AM Wei Xiao  wrote:
>
> Hi,
>
> The attached patch updates VFIXUPIMM* Intrinsics to align with the
> latest Intel® 64 and IA-32 Architectures Software Developer’s Manual
> (SDM).
> Tested with GCC regression test on x86, no regression.

A couple of remarks:

-_mm512_fixupimm_round_pd (__m512d __A, __m512d __B, __m512i __C,
+_mm512_fixupimm_round_pd (__m512d __B, __m512i __C,

 _mm512_mask_fixupimm_round_pd (__m512d __A, __mmask8 __U, __m512d __B,
__m512i __C, const int __imm, const int __R)

Some kind of the convention in avx512fintrin.h is that arguments are
named like this:

[ __m512. __W,] __mmask. __U, __m512x __A, __m512x __B, ..., const int
_imm, const int __R]. Can we please keep the same approach here? I'
mostly concerned that argument names don't start with __A.

-BDESC (OPTION_MASK_ISA_AVX512VL, CODE_FOR_avx512vl_fixupimmv4df_mask,
"__builtin_ia32_fixupimmpd256_mask", IX86_BUILTIN_FIXUPIMMPD256_MASK,
UNKNOWN, (int) V4DF_FTYPE_V4DF_V4DF_V4DI_INT_UQI)
...

You are removing the only users of e.g.
V4DF_FTYPE_V4DF_V4DF_V4DI_INT_UQI (and other definitions). If there
are no users left, can you also remove the relevant definitions?

> Is it ok?

Please repost the patch with above remarks addressed. These builtins
are mostly Intel affair, so in the hope that extensive testsuite in
this area catches all issues, I will just just rubber-stamp the
updated patch OK and leave the final approval to HJ.

Uros.

> Thanks
> Wei
>
> gcc/
> 2018-10-30 Wei Xiao 
>
> *config/i386/avx512fintrin.h: Update VFIXUPIMM* intrinsics.
> (_mm512_fixupimm_round_pd): Update parameters and builtin.
> (_mm512_maskz_fixupimm_round_pd): Ditto.
> (_mm512_fixupimm_round_ps): Ditto.
> (_mm512_maskz_fixupimm_round_ps): Ditto.
> (_mm_fixupimm_round_sd): Ditto.
> (_mm_maskz_fixupimm_round_sd): Ditto.
> (_mm_fixupimm_round_ss): Ditto.
> (_mm_maskz_fixupimm_round_ss): Ditto.
> (_mm512_fixupimm_pd): Ditto.
> (_mm512_maskz_fixupimm_pd): Ditto.
> (_mm512_fixupimm_ps): Ditto.
> (_mm512_maskz_fixupimm_ps): Ditto.
> (_mm_fixupimm_sd): Ditto.
> (_mm_maskz_fixupimm_sd): Ditto.
> (_mm_fixupimm_ss): Ditto.
> (_mm_maskz_fixupimm_ss): Ditto.
> (_mm512_mask_fixupimm_round_pd): Update builtin.
> (_mm512_mask_fixupimm_round_ps): Ditto.
> (_mm_mask_fixupimm_round_sd): Ditto.
> (_mm_mask_fixupimm_round_ss): Ditto.
> (_mm512_mask_fixupimm_pd): Ditto.
> (_mm512_mask_fixupimm_ps): Ditto.
> (_mm_mask_fixupimm_sd): Ditto.
> (_mm_mask_fixupimm_ss): Ditto.
> *config/i386/avx512vlintrin.h:
> (_mm256_fixupimm_pd): Update parameters and builtin.
> (_mm256_maskz_fixupimm_pd): Ditto.
> (_mm256_fixupimm_ps): Ditto.
> (_mm256_maskz_fixupimm_ps): Ditto.
> (_mm_fixupimm_pd): Ditto.
> (_mm_maskz_fixupimm_pd): Ditto.
> (_mm_fixupimm_ps): Ditto.
> (_mm_maskz_fixupimm_ps): Ditto.
> (_mm256_mask_fixupimm_pd): Update builtin.
> (_mm256_mask_fixupimm_ps): Ditto.
> (_mm_mask_fixupimm_pd): Ditto.
> (_mm_mask_fixupimm_ps): Ditto.
> *config/i386/i386-builtin-types.def: Add new builtin types.
> *config/i386/i386-builtin.def: Update builtin definitions.
> *config/i386/i386.c: Handle new builtin types.
> *config/i386/sse.md: Update VFIXUPIMM* patterns.
> (_fixupimm_maskz): Update.
> (_fixupimm): Update.
> (_fixupimm_mask): Update.
> (avx512f_sfixupimm_maskz): Update.
> (avx512f_sfixupimm): Update.
> (avx512f_sfixupimm_mask): Update.
> *config/i386/subst.md:
> (round_saeonly_sd_mask_operand4): Add new subst_attr.
> (round_saeonly_sd_mask_op4): Ditto.
> (round_saeonly_expand_operand5): Ditto.
> (round_saeonly_expand): Update.
>
> gcc/testsuite
> 2018-10-30 Wei Xiao 
>
> *gcc.target/i386/avx-1.c: Update tests for VFIXUPIMM* intrinsics.
> *gcc.target/i386/avx512f-vfixupimmpd-1.c: Ditto.
> *gcc.target/i386/avx512f-vfixupimmpd-2.c: Ditto.
> *gcc.target/i386/avx512f-vfixupimmps-1.c: Ditto.
> *gcc.target/i386/avx512f-vfixupimmsd-1.c: Ditto.
> *gcc.target/i386/avx512f-vfixupimmsd-2.c: Ditto.
> *gcc.target/i386/avx512f-vfixupimmss-1.c: Ditto.
> *gcc.target/i386/avx512f-vfixupimmss-2.c: Ditto.
> *gcc.target/i386/avx512vl-vfixupimmpd-1.c: Ditto.
> *gcc.target/i386/avx512vl-vfixupimmps-1.c: Ditto.
> *gcc.target/i386/sse-13.c: Ditto.
> *gcc.target/i386/sse-14.c: Ditto.
> *gcc.target/i386/sse-22.c: Ditto.
> *gcc.target/i386/sse-23.c: Ditto.
> *gcc.target/i386/testimm-10.c: Ditto.
> *gcc.target/i386/testround-1.c: Ditto.


Re: [build] Remove SPARC HAVE_AS_REGISTER_PSEUDO_OP

2018-11-01 Thread Joseph Myers
On Thu, 1 Nov 2018, Rainer Orth wrote:

> * One for ia64 in gcc_cv_as_ia64_ltoffx_ldxmov_relocs) ...
> 
> $as_echo '.text
>   addl r15 = @ltoffx(x#), gp
>   ;;
>   ld8.mov r16 = [r15], x#'[] > conftest.s

Thanks for pointing this out.  I've applied this patch to fix this by 
adding a newline at the end of the test input (which is what I did for all 
the cases where adding AC_LANG_SOURCE resulted in autoconf errors if the 
last line of the AC_LANG_SOURCE argument contained '#'; I don't know how 
related the issues are, but it's at least less cryptic for the reader than 
using a quadrigraph).


Avoid stray [] in ia64 assembler test.

Noted in .
Fix by adding extra newline in test input is analogous to many such
newlines added in cases where argument to a newly added AC_LANG_SOURCE
had a preprocessor directive on its last line.

2018-11-01  Joseph Myers  

* configure.ac (gcc_cv_as_ia64_ltoffx_ldxmov_relocs): Add newline
at end of assembler input text.
* configure: Regenerate.

Index: configure
===
--- configure   (revision 265722)
+++ configure   (working copy)
@@ -26646,7 +26646,8 @@
 $as_echo ' .text
addl r15 = @ltoffx(x#), gp
;;
-   ld8.mov r16 = [r15], x#'[] > conftest.s
+   ld8.mov r16 = [r15], x#
+' > conftest.s
 if { ac_try='$gcc_cv_as $gcc_cv_as_flags  -o conftest.o conftest.s >&5'
   { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
   (eval $ac_try) 2>&5
Index: configure.ac
===
--- configure.ac(revision 265722)
+++ configure.ac(working copy)
@@ -4550,7 +4550,8 @@
 [  .text
addl r15 = @ltoffx(x#), gp
;;
-   ld8.mov r16 = [[r15]], x#],,
+   ld8.mov r16 = [[r15]], x#
+],,
 [AC_DEFINE(HAVE_AS_LTOFFX_LDXMOV_RELOCS, 1,
  [Define if your assembler supports ltoffx and ldxmov relocations.])])
 

-- 
Joseph S. Myers
jos...@codesourcery.com


[committed] Fix GIMPLE error in gcc.dg/tree-ssa/cunroll-13.c for 16-bit int

2018-11-01 Thread Jozef Lawrynowicz

The test fails for msp430-elf which has 16-bit int by default. The test
uses __INT32_TYPE__ in place of int, when __SIZEOF_INT__ < 4.

gcc.dg/tree-ssa/cunroll-13.c: In function 't':
gcc.dg/tree-ssa/cunroll-13.c:13:1: error: type mismatch in binary expression
   13 | t (struct a * a)
  | ^
long int

long int

int

_1 = _2 + 1;
during GIMPLE pass: omplower
gcc.dg/tree-ssa/cunroll-13.c:13:1: internal compiler error: verify_gimple failed
0xba82fd verify_gimple_in_seq(gimple*)
../../gcc/tree-cfg.c:5082
0xa9d690 execute_function_todo
../../gcc/passes.c:1927
0xa9df29 execute_todo
../../gcc/passes.c:1979

There is a missing cast when the integer literal "1" is used, which causes the
above error. Committed the attached patch as "obvious".

2018-11-01  Jozef Lawrynowicz  

gcc/testsuite

   * gcc.dg/tree-ssa/cunroll-13.c: Add missing cast from literal to int32.

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/cunroll-13.c b/gcc/testsuite/gcc.dg/tree-ssa/cunroll-13.c
index baac6b4..096380a 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/cunroll-13.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/cunroll-13.c
@@ -29,7 +29,7 @@ bb_3:
   return;
 
 bb_4:
-  _1 = _2 + 1;
+  _1 = _2 + _Literal (i32) 1;
   a_6(D)->a[i_19] = _1;
   i_8 = i_19 + _Literal (i32) 1;
   if (i_8 <= _Literal (i32) 123455)


[build] Remove SPARC HAVE_AS_REGISTER_PSEUDO_OP

2018-11-01 Thread Rainer Orth
The autoconf 2.69 upgrade broke Solaris/SPARC bootstrap with as:
compiling stage1 libgcc fails with an assembler error:

/usr/ccs/bin/as: "/var/tmp//ccYQ2Dxc.s", line 32: error: detect global register 
use not covered .register pseudo-op
/usr/ccs/bin/as: "/var/tmp//ccYQ2Dxc.s", line 32: error: detect global register 
use not covered .register pseudo-op

The line in question is

srlx %g1,32,%g3

and comparing with older compiler output, I find that two lines were
lost:

-   .register   %g2, #scratch
-   .register   %g3, #scratch

They would be emitted by sparc.c (sparc_output_scratch_registers)
controlled by HAVE_AS_REGISTER_PSEUDO_OP.  Before the upgrade, this
would be 1 everywhere, now it's 0.  Checking gcc/config.log shows

configure:25347: checking assembler for .register
configure:25356: /usr/ccs/bin/as-o conftest.o conftest.s >&5
/usr/ccs/bin/as: "conftest.s", line 1: error: statement syntax
configure:25359: $? = 1
configure: failed program was
.register %g2, #scratch[]
configure:25370: result: no

and indeed gcc/configure now contains those superfluous trailing
brackets for

  [.register %g2, #scratch],,

$as_echo '.register %g2, #scratch'[] > conftest.s

I've found two more instances of this issue:

* One for ia64 in gcc_cv_as_ia64_ltoffx_ldxmov_relocs) ...

$as_echo '  .text
addl r15 = @ltoffx(x#), gp
;;
ld8.mov r16 = [r15], x#'[] > conftest.s

* ... and another in a yet unsubmitted patch of mine to support
  SHF_MERGE with Solaris as.

This is an incompatible change autoconf -Wall doesn't warn about.  It
can be avoided/fixed by using the quadrigraph corresponding to '#',
'@%:@'.

However, for the sparc case there's an even simpler solution: the test
was originally introduced as a workaround when some Solaris 7 assembler
(the first one to support 64-bit SPARC) lacked the .register pseudo-op.
These days, with Solaris 10 the oldest supported Solaris release, both
the Solaris 10 FCS as and the gas 2.15 bundled with Solaris 10 support
.register, so there's no need to check for that.

While I refuse to even try bootstrapping with either of those now
ancient assemblers, I manually checked that both pass the test code from
the current test.

So the current patch removes both the autoconf test and the uses of the
macro.  Solaris 11/SPARC Bootstraps with both as and gas currently
running.  Ok for mainline if they pass?

Rainer

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


2018-11-01  Rainer Orth  

* configure.ac (gcc_cv_as_sparc_register_op): Remove.
* configure: Regenerate.
* config.in: Regenerate.
* config/sparc/sparc.c (sparc_output_scratch_registers): Remove
HAVE_AS_REGISTER_PSEUDO_OP guard.
* config/sparc/sparc.h (ASM_ARCH64_SPEC): Remove
!HAVE_AS_REGISTER_PSEUDO_OP support.
(ASM_DECLARE_REGISTER_GLOBAL): Remove HAVE_AS_REGISTER_PSEUDO_OP
guard.

# HG changeset patch
# Parent  9f1fd4adf7454b08bcb179652a217c48e17cfa08
Remove SPARC HAVE_AS_REGISTER_PSEUDO_OP

diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -5583,7 +5583,6 @@ sparc_initial_elimination_offset (int to
 void
 sparc_output_scratch_registers (FILE *file ATTRIBUTE_UNUSED)
 {
-#ifdef HAVE_AS_REGISTER_PSEUDO_OP
   int i;
 
   if (TARGET_ARCH32)
@@ -5604,7 +5603,6 @@ sparc_output_scratch_registers (FILE *fi
 	}
   if (i == 3) i = 5;
 }
-#endif
 }
 
 #define PROBE_INTERVAL (1 << STACK_CHECK_PROBE_INTERVAL_EXP)
diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h
--- a/gcc/config/sparc/sparc.h
+++ b/gcc/config/sparc/sparc.h
@@ -365,11 +365,7 @@ extern enum cmodel sparc_cmodel;
This is what GAS uses.  Add %(asm_arch) to ASM_SPEC to enable.  */
 
 #define ASM_ARCH32_SPEC "-32"
-#ifdef HAVE_AS_REGISTER_PSEUDO_OP
 #define ASM_ARCH64_SPEC "-64 -no-undeclared-regs"
-#else
-#define ASM_ARCH64_SPEC "-64"
-#endif
 #define ASM_ARCH_DEFAULT_SPEC \
 (DEFAULT_ARCH32_P ? ASM_ARCH32_SPEC : ASM_ARCH64_SPEC)
 
@@ -1197,7 +1193,6 @@ init_cumulative_args (& (CUM), (FNTYPE),
 
 extern GTY(()) char sparc_hard_reg_printed[8];
 
-#ifdef HAVE_AS_REGISTER_PSEUDO_OP
 #define ASM_DECLARE_REGISTER_GLOBAL(FILE, DECL, REGNO, NAME)		\
 do {	\
   if (TARGET_ARCH64)			\
@@ -1216,8 +1211,6 @@ do {	\
 	  }\
 }	\
 } while (0)
-#endif
-
 
 /* Emit rtl for profiling.  */
 #define PROFILE_HOOK(LABEL)   sparc_profile_hook (LABEL)
diff --git a/gcc/configure.ac b/gcc/configure.ac
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -4077,11 +4077,6 @@ EOF
 ;;
 
   sparc*-*-*)
-gcc_GAS_CHECK_FEATURE([.register], gcc_cv_as_sparc_register_op,,,
-  [.register %g2, #scratch],,
-  [AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1,
-		[Define if your assembler supports .register.])])
-
 gcc_GAS_CHECK_FEATUR

[PATCH v2, middle end]: Fix PR58372, internal compiler error: ix86_compute_frame_layout

2018-11-01 Thread Uros Bizjak
Hello!

v2 of the patch hits the real problem: in pass_expand::execute
finish_eh_generation is called after expand_stack_alignment is called.
Construction of SjLj landing pads calls emit_library_call, which can
change crtl->preferred_stack_boundary value after all dependant
variables are already calculated by expand_stack_alignment.

The solution is to move the call to finish_eh_generation in front of
the call to expand_stack_alignment.

2018-11-01  Uros Bizjak  

PR middle-end/58372
* cfgexpand.c (pass_expand::execute): Move the call to
finish_eh_generation in front of the call to expand_stack_alignment.

testsuite/ChangeLog:

2018-11-01  Uros Bizjak  

PR middle-end/58372
* g++.target/i386/pr58372.C: New test.

Patch was bootstrapped and regression tested on x86_64-linux-gnu
{,-m32}, all default languages plus go. Additionally, the testcase
from PR (and a couple of similar ones) were compiled for
i686-w64-mingw32 target with various combinations of
-mpreferred-stack-boundary= -mincoming-stack-boundary= -mforce-drap
and -m{no-}accumulate-outgoing-args.

OK for mainline and release branches?

Uros.
Index: cfgexpand.c
===
--- cfgexpand.c (revision 265582)
+++ cfgexpand.c (working copy)
@@ -6510,6 +6510,12 @@ pass_expand::execute (function *fun)
   find_many_sub_basic_blocks (blocks);
   purge_all_dead_edges ();
 
+  /* After initial rtl generation, call back to finish generating
+ exception support code.  We need to do this before cleaning up
+ the CFG as the code does not expect dead landing pads.  */
+  if (fun->eh->region_tree != NULL)
+finish_eh_generation ();
+
   expand_stack_alignment ();
 
   /* Fixup REG_EQUIV notes in the prologue if there are tailcalls in this
@@ -6517,12 +6523,6 @@ pass_expand::execute (function *fun)
   if (crtl->tail_call_emit)
 fixup_tail_calls ();
 
-  /* After initial rtl generation, call back to finish generating
- exception support code.  We need to do this before cleaning up
- the CFG as the code does not expect dead landing pads.  */
-  if (fun->eh->region_tree != NULL)
-finish_eh_generation ();
-
   /* BB subdivision may have created basic blocks that are are only reachable
  from unlikely bbs but not marked as such in the profile.  */
   if (optimize)
Index: testsuite/g++.target/i386/pr58372.C
===
--- testsuite/g++.target/i386/pr58372.C (nonexistent)
+++ testsuite/g++.target/i386/pr58372.C (working copy)
@@ -0,0 +1,9 @@
+/* PR target/58372 */
+/* { dg-do compile { target c++14 } } */
+/* { dg-options "-O2" } */
+
+__attribute__ ((__target__ ("rdrnd")))
+void f (unsigned int *b) noexcept
+{
+  __builtin_ia32_rdrand32_step (b);
+}


Re: C++ PATCH to Implement P0846R0, ADL and function templates [v2]

2018-11-01 Thread Jason Merrill

On 10/31/18 6:45 PM, Marek Polacek wrote:

On Mon, Oct 29, 2018 at 05:59:13PM -0400, Jason Merrill wrote:

On 10/28/18 3:56 PM, Marek Polacek wrote:

This patch implements P0846R0: ADL and Function Templates that are not Visible

whereby a name for which a normal lookup produces either no result or finds one
or more functions and that is followed by a "<" would be treated as if a 
function
template name had been found and would cause ADL to be performed.  Thus e.g.

namespace N {
struct S { };
template void f(S);
}

void
bar (N::S s)
{
f<3>(s);
}

will now compile; ADL will find N::f.  The gist of the approach I took is in
cp_parser_template_name and setting TEMPLATE_ID_TRY_ADL_P.


Why do you need that flag?  Can't you tell from the first operand of the
TEMPLATE_ID_EXPR whether it's suitable?


I needed to distinguish between the two kinds of identifiers
cp_parser_template_name can return.  But I found out I can (ab)use
IDENTIFIER_BINDING for that.  If it's empty then name lookup didn't find
anything (push_binding wasn't called for such an id), so we should try ADL.
Otherwise it's a dependent name and we need to wait for instantiation.


There's something I'm not clear on; the proposal talks about an
unqualified-id followed by a <, which is also the case for

a.foo < 1;

which is "postfix-expression . unqualified-id <", but treating "foo" as a
template name would break valid programs.  I don't think this proposal should
be in effect for class member accesses, so I've disabled it by using scoped_p
below.  See fn-template8.C for a complete testcase for this scenario.


Agreed; ADL doesn't apply to class member access, so it shouldn't apply
here.  Sent mail to the core reflector.


Great, thanks for that.


@@ -7165,7 +7165,9 @@ cp_parser_postfix_expression (cp_parser *parser, bool 
address_p, bool cast_p,
if (idk == CP_ID_KIND_UNQUALIFIED
|| idk == CP_ID_KIND_TEMPLATE_ID)
  {
-   if (identifier_p (postfix_expression))
+   if (identifier_p (postfix_expression)
+   || (TREE_CODE (postfix_expression) == TEMPLATE_ID_EXPR
+   && TEMPLATE_ID_TRY_ADL_P (postfix_expression)))


Here I think you can check whether the first operand is an identifier.


Changed, along with checking for IDENTIFIER_BINDING.  E.g. this is a test that
would fail if we tried ADL for a template-id with any identifier:

   template  struct X {
 X() { fn<>(0); }
 template  void fn();
   };

here we need to perform two-stage lookup.


I don't see why; when we look up fn we find the member template, and we 
should remember that.  I think this code:


  /* If DECL is dependent, and refers to a function, then just return  
 its name; we will look it up again during template instantiation.  */

  if (DECL_FUNCTION_TEMPLATE_P (decl) || !DECL_P (decl))
{
  tree scope = ovl_scope (decl);
  if (TYPE_P (scope) && dependent_type_p (scope))
return identifier;
}


should go so that returning an identifier can consistently mean nothing 
found.


Jason


CES 2019

2018-11-01 Thread everly madison
Hi, 

 

I understand that you are one of the Exhibitors of "Consumer Electronics
Show - CES 2019" taking place on DEC 8 - 11, 2019, at Las Vegas, NV.

 

I was wondering if you would be interested in acquiring Consumer Electronics
Show - CES 2019 - Attendees List for booth invites, drive qualified traffic,
appointment setting, networking and various marketing initiative.

 

Each record will contain details like: Contact Name, Title, Phone Number,
Physical address, State/City, Company Name, Company URL and most importantly
verified email addresses.

 

If you are interested, drop me a line. We will get back to you with pricing,
counts and other information for your review.

 

Thank you and I look forward to hearing from you.

 

Best Regards,

Everly Rose, Database Manager 

If you do not wish to receive future emails from us, please reply as 'leave
out'

 

 



Re: [PATCH][rs6000] cleanup and rename rs6000_address_for_fpconvert

2018-11-01 Thread Segher Boessenkool
Hi!

On Thu, Nov 01, 2018 at 09:00:08AM -0500, Aaron Sawdey wrote:
>   (rs6000_address_for_fpconvert) Combine with
>   rs6000_force_indexed_or_indirect_mem.

(missing colon)

>  rtx
> -rs6000_address_for_fpconvert (rtx x)
> +rs6000_force_indexed_or_indirect_mem (rtx x)
>  {
> -  rtx addr;
> +  machine_mode m = GET_MODE (x);

Please spell this out, "mode".

Okay for trunk.  Thank you for doing this cleanup!


Segher


Re: [PATCH, ARM, ping] PR85434: Prevent spilling of stack protector guard's address on ARM

2018-11-01 Thread Thomas Preudhomme
Ping?

Best regards,

Thomas
On Fri, 26 Oct 2018 at 22:41, Thomas Preudhomme
 wrote:
>
> Hi,
>
> Please find updated patch to fix PR85434: spilling of stack protector
> guard's address on ARM. Quite a few changes have been made to the ARM
> part since last round of review so I think it makes more sense to
> review it anew. Ran bootstrap + regression testsuite + glibc build +
> glibc regression testsuite for Arm and Thumb-2 and bootstrap +
> regression testsuite for Thumb-1. GCC's regression testsuite was run
> in 3 configurations in all those cases:
>
> - default configuration (no RUNTESTFLAGS)
> - with -fstack-protector-all
> - with -fPIC -fstack-protector-all (to exercise both codepath in stack
> protector's split code)
>
> None of this show any regression beyond some new scan fail with
> -fstack-protector-all or -fPIC due to unexpected code sequence for the
> testcases concerned and some guality swing due to less optimization
> with new stack protector on.
>
> Patch description and ChangeLog below.
>
> In case of high register pressure in PIC mode, address of the stack
> protector's guard can be spilled on ARM targets as shown in PR85434,
> thus allowing an attacker to control what the canary would be compared
> against. ARM does lack stack_protect_set and stack_protect_test insn
> patterns, defining them does not help as the address is expanded
> regularly and the patterns only deal with the copy and test of the
> guard with the canary.
>
> This problem does not occur for x86 targets because the PIC access and
> the test can be done in the same instruction. Aarch64 is exempt too
> because PIC access insn pattern are mov of UNSPEC which prevents it from
> the second access in the epilogue being CSEd in cse_local pass with the
> first access in the prologue.
>
> The approach followed here is to create new "combined" set and test
> standard pattern names that take the unexpanded guard and do the set or
> test. This allows the target to use an opaque pattern (eg. using UNSPEC)
> to hide the individual instructions being generated to the compiler and
> split the pattern into generic load, compare and branch instruction
> after register allocator, therefore avoiding any spilling. This is here
> implemented for the ARM targets. For targets not implementing these new
> standard pattern names, the existing stack_protect_set and
> stack_protect_test pattern names are used.
>
> To be able to split PIC access after register allocation, the functions
> had to be augmented to force a new PIC register load and to control
> which register it loads into. This is because sharing the PIC register
> between prologue and epilogue could lead to spilling due to CSE again
> which an attacker could use to control what the canary gets compared
> against.
>
> ChangeLog entries are as follows:
>
> *** gcc/ChangeLog ***
>
> 2018-10-26  Thomas Preud'homme  
>
> * target-insns.def (stack_protect_combined_set): Define new standard
> pattern name.
> (stack_protect_combined_test): Likewise.
> * cfgexpand.c (stack_protect_prologue): Try new
> stack_protect_combined_set pattern first.
> * function.c (stack_protect_epilogue): Try new
> stack_protect_combined_test pattern first.
> * config/arm/arm.c (require_pic_register): Add pic_reg and compute_now
> parameters to control which register to use as PIC register and force
> reloading PIC register respectively.  Insert in the stream of insns if
> possible.
> (legitimize_pic_address): Expose above new parameters in prototype and
> adapt recursive calls accordingly.  Use pic_reg if non null instead of
> cached one.
> (arm_load_pic_register): Add pic_reg parameter and use it if non null.
> (arm_legitimize_address): Adapt to new legitimize_pic_address
> prototype.
> (thumb_legitimize_address): Likewise.
> (arm_emit_call_insn): Adapt to require_pic_register prototype change.
> (arm_expand_prologue): Adapt to arm_load_pic_register prototype change.
> (thumb1_expand_prologue): Likewise.
> * config/arm/arm-protos.h (legitimize_pic_address): Adapt to prototype
> change.
> (arm_load_pic_register): Likewise.
> * config/arm/predicated.md (guard_addr_operand): New predicate.
> (guard_operand): New predicate.
> * config/arm/arm.md (movsi expander): Adapt to legitimize_pic_address
> prototype change.
> (builtin_setjmp_receiver expander): Adapt to thumb1_expand_prologue
> prototype change.
> (stack_protect_combined_set): New expander..
> (stack_protect_combined_set_insn): New insn_and_split pattern.
> (stack_protect_set_insn): New insn pattern.
> (stack_protect_combined_test): New expander.
> (stack_protect_combined_test_insn): New insn_and_split pattern.
> (arm_stack_protect_test_insn): New insn pattern.
> * config/arm/thumb1.md (thumb1_stack_protect_test_insn): New insn pattern.
> * config/arm/unspecs.md (UNSPEC_SP_SET): New unspec.
> (UNSPEC_SP_TEST): Likewise.
> * doc/md.texi (stack_protect_combined_set): Document new standard
> pattern name.
> (stack_protect_set): Clarify that the operand for guard's a

[PATCH v3 3/3] PR preprocessor/83173: Enhance -fdump-internal-locations output

2018-11-01 Thread Mike Gulick
2017-10-31  Mike Gulick  

PR preprocessor/83173
* gcc/input.c (dump_location_info): Dump reason and
included_from fields from line_map_ordinary struct.  Fix
indentation when location > 5 digits.

* libcpp/location-example.txt: Update example
-fdump-internal-locations output.
---
 gcc/input.c |  49 +-
 libcpp/location-example.txt | 333 +---
 2 files changed, 241 insertions(+), 141 deletions(-)

diff --git a/gcc/input.c b/gcc/input.c
index a94a010f353..f938a37f20e 100644
--- a/gcc/input.c
+++ b/gcc/input.c
@@ -1075,6 +1075,17 @@ dump_labelled_location_range (FILE *stream,
   fprintf (stream, "\n");
 }
 
+#define NUM_DIGITS(x) ((x) >= 10 ? 10 : \
+  (x) >= 1 ? 9 : \
+  (x) >= 1000 ? 8 : \
+  (x) >= 100 ? 7 : \
+  (x) >= 10 ? 6 : \
+  (x) >= 1 ? 5 : \
+  (x) >= 1000 ? 4 : \
+  (x) >= 100 ? 3 : \
+  (x) >= 10 ? 2 : \
+  1)
+
 /* Write a visualization of the locations in the line_table to STREAM.  */
 
 void
@@ -1104,6 +1115,35 @@ dump_location_info (FILE *stream)
   map->m_column_and_range_bits - map->m_range_bits);
   fprintf (stream, "  range bits: %i\n",
   map->m_range_bits);
+  const char * reason;
+  switch (map->reason) {
+  case LC_ENTER:
+   reason = "LC_ENTER";
+   break;
+  case LC_LEAVE:
+   reason = "LC_LEAVE";
+   break;
+  case LC_RENAME:
+   reason = "LC_RENAME";
+   break;
+  case LC_RENAME_VERBATIM:
+   reason = "LC_RENAME_VERBATIM";
+   break;
+  case LC_ENTER_MACRO:
+   reason = "LC_RENAME_MACRO";
+   break;
+  default:
+   reason = "Unknown";
+  }
+  fprintf (stream, "  reason: %d (%s)\n", map->reason, reason);
+
+  const line_map_ordinary *includer_map
+   = linemap_included_from_linemap (line_table, map);
+  fprintf (stream, "  included from map: %d\n",
+  includer_map ? int (includer_map - 
line_table->info_ordinary.maps)
+  : -1);
+  fprintf (stream, "  included from location: %d\n",
+  linemap_included_from (map));
 
   /* Render the span of source lines that this "map" covers.  */
   for (source_location loc = MAP_START_LOCATION (map);
@@ -1137,7 +1177,14 @@ dump_location_info (FILE *stream)
  if (max_col > line_text.length ())
max_col = line_text.length () + 1;
 
- int indent = 14 + strlen (exploc.file);
+ int len_lnum = NUM_DIGITS (exploc.line);
+ if (len_lnum < 3)
+   len_lnum = 3;
+ int len_loc = NUM_DIGITS (loc);
+ if (len_loc < 5)
+   len_loc = 5;
+
+ int indent = 6 + strlen (exploc.file) + len_lnum + len_loc;
 
  /* Thousands.  */
  if (end_location > 999)
diff --git a/libcpp/location-example.txt b/libcpp/location-example.txt
index 14b5c2e284a..dc448b0493e 100644
--- a/libcpp/location-example.txt
+++ b/libcpp/location-example.txt
@@ -33,8 +33,12 @@ ORDINARY MAP: 0
   source_location interval: 32 <= loc < 64
   file: test.c
   starting at line: 1
-  column bits: 12
+  column and range bits: 12
+  column bits: 7
   range bits: 5
+  reason: 0 (LC_ENTER)
+  included from map: -1
+  included from location: 0
 test.c:  1|loc:   32|#include "test.h"
 |69269258258148147
 |46802468024680246
@@ -43,186 +47,235 @@ ORDINARY MAP: 1
   source_location interval: 64 <= loc < 96
   file: 
   starting at line: 0
+  column and range bits: 0
   column bits: 0
   range bits: 0
+  reason: 2 (LC_RENAME)
+  included from map: -1
+  included from location: 0
 
 ORDINARY MAP: 2
   source_location interval: 96 <= loc < 128
   file: 
   starting at line: 0
+  column and range bits: 0
   column bits: 0
   range bits: 0
+  reason: 2 (LC_RENAME)
+  included from map: -1
+  included from location: 0
 
 ORDINARY MAP: 3
-  source_location interval: 128 <= loc < 160128
+  source_location interval: 128 <= loc < 250240
   file: /usr/include/stdc-predef.h
   starting at line: 1
-  column bits: 12
+  column and range bits: 12
+  column bits: 7
   range bits: 5
+  reason: 0 (LC_ENTER)
+  included from map: 2
+  included from location: 127
 (contents of /usr/include/stdc-predef.h snipped for brevity)
 
 ORDINARY MAP: 4
-  source_location interval: 160128 <= loc < 160160
+  source_location interval: 250240 <= loc < 250272
   file: 
   starting at line: 32
-  column bits: 12
+  column and range bits: 12
+  column bits: 7
   range bits: 5
+  reason: 1 (LC_LEAVE)
+  included from map: -1
+  included from location: 0
 
 ORDINARY MAP: 5
-  source_location interval: 160160 <= loc < 164256
+  source_location interval: 250272 <= loc < 254368
   file: test.c
   starti

[PATCH v3 2/3] PR preprocessor/83173: New test

2018-11-01 Thread Mike Gulick
2018-10-31  Mike Gulick  

PR preprocessor/83173
* gcc.dg/plugin/location-overflow-test-pr83173.c: New test.
* gcc.dg/plugin/location-overflow-test-pr83173.h: Header for
pr83173.c.
* gcc.dg/plugin/location-overflow-test-pr83173-1.h: Header for
pr83173.c.
* gcc.dg/plugin/location-overflow-test-pr83173-2.h: Header for
pr83173.c.
* gcc.dg/plugin/location_overflow_plugin.c: Use PLUGIN_PRAGMAS
instead of PLUGIN_START_UNIT.
* gcc.dg/plugin/plugin.exp: Enable new test.
---
 .../plugin/location-overflow-test-pr83173-1.h |  2 ++
 .../plugin/location-overflow-test-pr83173-2.h |  2 ++
 .../plugin/location-overflow-test-pr83173.c   | 21 +++
 .../plugin/location-overflow-test-pr83173.h   |  2 ++
 .../gcc.dg/plugin/location_overflow_plugin.c  | 13 +++-
 gcc/testsuite/gcc.dg/plugin/plugin.exp|  3 ++-
 6 files changed, 37 insertions(+), 6 deletions(-)
 create mode 100644 
gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr83173-1.h
 create mode 100644 
gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr83173-2.h
 create mode 100644 gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr83173.c
 create mode 100644 gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr83173.h

diff --git a/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr83173-1.h 
b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr83173-1.h
new file mode 100644
index 000..f47dc3643c2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr83173-1.h
@@ -0,0 +1,2 @@
+#pragma once
+#define LOCATION_OVERFLOW_TEST_PR83173_1_H
diff --git a/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr83173-2.h 
b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr83173-2.h
new file mode 100644
index 000..bc23ed2a188
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr83173-2.h
@@ -0,0 +1,2 @@
+#pragma once
+#define LOCATION_OVERFLOW_TEST_PR83173_2_H
diff --git a/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr83173.c 
b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr83173.c
new file mode 100644
index 000..2d581283474
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr83173.c
@@ -0,0 +1,21 @@
+/*
+  { dg-options "-fplugin-arg-location_overflow_plugin-value=0x6001" }
+  { dg-do preprocess }
+*/
+
+#include "location-overflow-test-pr83173.h"
+
+int
+main ()
+{
+  return 0;
+}
+
+/*
+  The preprocessor output should contain
+  '# 1 "path/to/location-overflow-test-pr83173-1.h" 1', but should not
+  contain any other references to location-overflow-test-pr83183-1.h.
+
+  { dg-final { scan-file location-overflow-test-pr83173.i "# 1 
\[^\r\n\]+location-overflow-test-pr83173-1\.h\" 1" } }
+  { dg-final { scan-file-not location-overflow-test-pr83173.i "# (?!1 
\[^\r\n\]+location-overflow-test-pr83173-1\.h\" 1)\[0-9\]+ 
\[^\r\n\]+location-overflow-test-pr83173-1\.h\"" } }
+*/
diff --git a/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr83173.h 
b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr83173.h
new file mode 100644
index 000..49076f7ea3c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr83173.h
@@ -0,0 +1,2 @@
+#include "location-overflow-test-pr83173-1.h"
+#include "location-overflow-test-pr83173-2.h"
diff --git a/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.c 
b/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.c
index 3644d9fd82e..317232bc19d 100644
--- a/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.c
+++ b/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.c
@@ -12,11 +12,14 @@ int plugin_is_GPL_compatible;
 
 static location_t base_location;
 
-/* Callback handler for the PLUGIN_START_UNIT event; pretend
-   we parsed a very large include file.  */
+/* Callback handler for the PLUGIN_PRAGMAS event; pretend we parsed a
+   very large include file.  This is used to set the initial line table
+   offset for the preprocessor, to make it appear as if we had parsed a
+   very large file.  PRAGMA_START_UNIT is not suitable here as is not
+   invoked during the preprocessor stage.  */
 
 static void
-on_start_unit (void */*gcc_data*/, void */*user_data*/)
+on_pragma_registration (void */*gcc_data*/, void */*user_data*/)
 {
   /* Act as if we've already parsed a large body of code;
  so that we can simulate various fallbacks in libcpp:
@@ -79,8 +82,8 @@ plugin_init (struct plugin_name_args *plugin_info,
 error_at (UNKNOWN_LOCATION, "missing plugin argument");
 
   register_callback (plugin_info->base_name,
-PLUGIN_START_UNIT,
-on_start_unit,
+PLUGIN_PRAGMAS,
+on_pragma_registration,
 NULL); /* void *user_data */
 
   /* Hack in additional testing, based on the exact value supplied.  */
diff --git a/gcc/testsuite/gcc.dg/plugin/plugin.exp 
b/gcc/testsuite/gcc.dg/plugin/plugin.exp
index d9

[PATCH v3 0/3] PR preprocessor/83173: C preprocessor generates incorrect linemarkers

2018-11-01 Thread Mike Gulick
Hi,

Changes in v3:
I haven't gotten a response in several months, so I'm reposting these
patches.  I split up the enhancement to the -fdump-internal-locations
output from the actual bugfix.  Hopefully this will make these easier to
review.  I rebased these patches on the gcc master and had to make one
minor change to patch 3/3 to account for removal of the
ORDINARY_MAP_INCLUDER_FILE_INDEX macro that was made back in August.

We have been using this patch internally for the last 9 months without
any issues, and the some other users have indicated the same on the bug
report.  Please let me know if you have any feedback, and how I should
proceed.  I do not have gcc contributor paperwork in place, as I believe
that needs to be initiated by a maintainer, but I do have an employer
disclaimer already approved, so the process should be simple.

Thanks,
Mike

Mike Gulick (3):
  PR preprocessor/83173: Additional check before decrementing
highest_location
  PR preprocessor/83173: New test
  PR preprocessor/83173: Enhance -fdump-internal-locations output

 gcc/input.c   |  49 ++-
 .../plugin/location-overflow-test-pr83173-1.h |   2 +
 .../plugin/location-overflow-test-pr83173-2.h |   2 +
 .../plugin/location-overflow-test-pr83173.c   |  21 ++
 .../plugin/location-overflow-test-pr83173.h   |   2 +
 .../gcc.dg/plugin/location_overflow_plugin.c  |  13 +-
 gcc/testsuite/gcc.dg/plugin/plugin.exp|   3 +-
 libcpp/files.c|  32 +-
 libcpp/location-example.txt   | 333 ++
 9 files changed, 301 insertions(+), 156 deletions(-)
 create mode 100644 
gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr83173-1.h
 create mode 100644 
gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr83173-2.h
 create mode 100644 gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr83173.c
 create mode 100644 gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr83173.h

-- 
2.19.1



[PATCH v3 1/3] PR preprocessor/83173: Additional check before decrementing highest_location

2018-11-01 Thread Mike Gulick
2018-10-31  Mike Gulick  

PR preprocessor/83173
* libcpp/files.c (_cpp_stack_include): Check if
line_table->highest_location is past current line before
decrementing.
---
 libcpp/files.c | 32 +++-
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/libcpp/files.c b/libcpp/files.c
index 08b7c647c91..c0165fe64e4 100644
--- a/libcpp/files.c
+++ b/libcpp/files.c
@@ -1012,6 +1012,7 @@ _cpp_stack_include (cpp_reader *pfile, const char *fname, 
int angle_brackets,
   struct cpp_dir *dir;
   _cpp_file *file;
   bool stacked;
+  bool decremented = false;
 
   /* For -include command-line flags we have type == IT_CMDLINE.
  When the first -include file is processed we have the case, where
@@ -1035,20 +1036,33 @@ _cpp_stack_include (cpp_reader *pfile, const char 
*fname, int angle_brackets,
 return false;
 
   /* Compensate for the increment in linemap_add that occurs if
-  _cpp_stack_file actually stacks the file.  In the case of a
- normal #include, we're currently at the start of the line
- *following* the #include.  A separate source_location for this
- location makes no sense (until we do the LC_LEAVE), and
- complicates LAST_SOURCE_LINE_LOCATION.  This does not apply if we
- found a PCH file (in which case linemap_add is not called) or we
- were included from the command-line.  */
+ _cpp_stack_file actually stacks the file.  In the case of a normal
+ #include, we're currently at the start of the line *following* the
+ #include.  A separate source_location for this location makes no
+ sense (until we do the LC_LEAVE), and complicates
+ LAST_SOURCE_LINE_LOCATION.  This does not apply if we found a PCH
+ file (in which case linemap_add is not called) or we were included
+ from the command-line.  In the case that the #include is the last
+ line in the file, highest_location still points to the current
+ line, not the start of the next line, so we do not decrement in
+ this case.  See plugin/location-overflow-test-pr83173.h for an
+ example.  */
   if (file->pchname == NULL && file->err_no == 0
   && type != IT_CMDLINE && type != IT_DEFAULT)
-pfile->line_table->highest_location--;
+{
+  int highest_line = linemap_get_expansion_line (pfile->line_table,
+
pfile->line_table->highest_location);
+  int source_line = linemap_get_expansion_line (pfile->line_table, loc);
+  if (highest_line > source_line)
+   {
+ pfile->line_table->highest_location--;
+ decremented = true;
+   }
+}
 
   stacked = _cpp_stack_file (pfile, file, type == IT_IMPORT, loc);
 
-  if (!stacked)
+  if (decremented && !stacked)
 /* _cpp_stack_file didn't stack the file, so let's rollback the
compensation dance we performed above.  */
 pfile->line_table->highest_location++;
-- 
2.19.1



Re: [PATCH] Fix PR 86572

2018-11-01 Thread Bernd Edlinger
Ping...

For this patch here: https://gcc.gnu.org/ml/gcc-patches/2018-10/msg01336.html

Thanks
Bernd.

On 10/22/18 5:08 PM, Bernd Edlinger wrote:
> Hi!
> 
> This makes c_strlen avoid an unsafe strlen folding of const arguments
> with non-const offset.  Currently a negative out of bounds offset
> makes the strlen function return an extremely large number, and
> at the same time, prevents the VRP machinery, to determine the correct
> range if the strlen function in this case.
> 
> Fixed by doing the whole computation in size_t and casting the
> result back to ssize_t.
> 
> 
> Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
> Is it OK for trunk?
> 
> 
> Thanks
> Bernd.


[PING] [PATCH] Fix PR 87672

2018-11-01 Thread Bernd Edlinger
Ping...

I'd like to ping this patch: 
https://gcc.gnu.org/ml/gcc-patches/2018-10/msg01335.html

Thanks
Bernd.

On 10/22/18 4:59 PM, Bernd Edlinger wrote:
> Hi!
> 
> This fixes an ICE which was exposed by a previous patch of mine,
> and a wrong transformation from strcat_chk => strcpy_chk,
> which fails to adjust the object size, thus allowing too much
> memory to be accessed.
> 
> 
> Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
> Is it OK for trunk?
> 
> 
> Thanks
> Bernd.


[PING**3] [PATCH] Fix not properly nul-terminated string constants in JIT

2018-11-01 Thread Bernd Edlinger
Ping...

On 10/10/18 9:43 PM, Bernd Edlinger wrote:
> Ping...
> 
> 
> On 08/26/18 21:40, Bernd Edlinger wrote:
>> Ping...
>>
>> This is just plain wrong, independent
>> of any STRING_CST semantic issues.
>>
>> The original patch (retested on current trunk) is
>> here: https://gcc.gnu.org/ml/gcc-patches/2018-08/msg00370.html
>>
>>
>> On 08/05/18 18:59, Bernd Edlinger wrote:
>>> Hi!
>>>
>>>
>>> My other patch with adds assertions to varasm.c regarding correct
>>> nul termination of sting literals did make these incorrect string
>>> constants in JIT frontend fail.
>>>
>>> The string constants are not nul terminated if their length exceeds
>>> 200 characters.  The test cases do not use strings of that size where
>>> that would make a difference.  But using a fixed index type is clearly
>>> wrong.
>>>
>>> This patch removes the fixed char[200] array type from playback::context,
>>> and uses build_string_literal instead of using build_string directly.
>>>
>>>
>>> Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
>>> Is it OK for trunk?
>>>
>>>
>>> Thanks
>>> Bernd.


Re: [PATCH] Fix PRs70359/86270

2018-11-01 Thread H.J. Lu
On Wed, Oct 31, 2018 at 4:56 AM Richard Biener  wrote:
>
> On Tue, 30 Oct 2018, Richard Biener wrote:
>
> >
> > This picks up work from earlier this year where Aldy worked on
> > undoing forwprop during out-of-SSA to improve coalescing across
> > backedges.
> >
> > The following patch first rectifies the existing code which
> > is meant to insert necessary copies in places where it then
> > allows coalescing and thus avoids splitting of the backedge.
> >
> > The current code has issues with handling conflicts with uses
> > in the exit condition badly which is why the patch instead
> > of on the backedge inserts the copy before the definition
> > of the backedge value.  It also expands the constraint of
> > handling only single-BB loops (because of trivially_conflicts_p
> > restrictions).  Also we can coalesce vars with different
> > SSA_NAME_VAR just fine now.
> >
> > This makes the cases in the PRs keep their natural loop
> > form where originally they had their backedge split because
> > the inserted copies didn't do the job.
> >
> > The testcases may be a bit awkward (and hopefully survive
> > solaris assembler woes...)
> >
> > Bootstrap and regtest running on x86_64-unknown-linux-gnu.
>
> The following is what I have applied.
>
> Richard.
>
> From 5b774992b3863931ccbba13effc9efcea304610e Mon Sep 17 00:00:00 2001
> From: Richard Guenther 
> Date: Tue, 30 Oct 2018 14:46:05 +0100
> Subject: [PATCH] fix-pr70359
>
> PR middle-end/70359
> PR middle-end/86270
> * tree-outof-ssa.c (insert_backedge_copies): Restrict
> copy generation to useful cases.  Place the copy before
> the definition of the backedge value when possible.
>

This caused:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87852

-- 
H.J.


[PATCH][rs6000] cleanup and rename rs6000_address_for_fpconvert

2018-11-01 Thread Aaron Sawdey
This patch combines the duties of rs6000_address_for_fpconvert into
rs6000_force_indexed_or_indirect_mem which I recently added, and changes
all calls to use the latter. The new function name is more descriptive of what
is actually going on. This now uses indexed_or_indirect_operand() to test
the incoming rtx which matches what the insns this is used to prepare for
are using as their predicate.

Bootstrap/regtest passes on ppc64le (power7, power9), ok for trunk?



2018-11-01  Aaron Sawdey  

* config/rs6000/rs6000-protos.h (rs6000_address_for_fpconvert): Remove
prototype.
* config/rs6000/rs6000.c (rs6000_force_indexed_or_indirect_mem):
Combine with rs6000_address_for_fpconvert.
(rs6000_address_for_fpconvert) Combine with
rs6000_force_indexed_or_indirect_mem.
(rs6000_expand_vector_init): Change function call from
rs6000_address_for_fpconvert to rs6000_force_indexed_or_indirect_mem.
* config/rs6000/rs6000.md (floatsi2_lfiwax): Change call from
rs6000_address_for_fpconvert to rs6000_force_indexed_or_indirect_mem.
(floatsi2_lfiwax_mem): Ditto.
(floatunssi2_lfiwzx): Ditto.
(floatunssi2_lfiwzx_mem): Ditto.
(float2): Ditto.
(floatuns2): Ditto.
(fix_truncsi2_stfiwx): Ditto.
(fixuns_truncsi2_stfiwx): Ditto.
(float_si2_hw): Ditto.
(floatuns_si2_hw): Ditto.
* config/rs6000/vsx.md (*vsx_extract_si): Ditto.
(vsx_splat_): Ditto.




Index: gcc/config/rs6000/rs6000-protos.h
===
--- gcc/config/rs6000/rs6000-protos.h   (revision 265637)
+++ gcc/config/rs6000/rs6000-protos.h   (working copy)
@@ -153,7 +153,6 @@

 extern rtx rs6000_machopic_legitimize_pic_address (rtx, machine_mode,
   rtx);
-extern rtx rs6000_address_for_fpconvert (rtx);
 extern rtx rs6000_allocate_stack_temp (machine_mode, bool, bool);
 extern align_flags rs6000_loop_align (rtx);
 extern void rs6000_split_logical (rtx [], enum rtx_code, bool, bool, bool);
Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (revision 265637)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -6560,7 +6560,7 @@
{
  rtx element0 = XVECEXP (vals, 0, 0);
  if (MEM_P (element0))
-   element0 = rs6000_address_for_fpconvert (element0);
+   element0 = rs6000_force_indexed_or_indirect_mem (element0);
  else
element0 = force_reg (SImode, element0);

@@ -6601,7 +6601,7 @@
  if (TARGET_P9_VECTOR)
{
  if (MEM_P (element0))
-   element0 = rs6000_address_for_fpconvert (element0);
+   element0 = rs6000_force_indexed_or_indirect_mem (element0);

  emit_insn (gen_vsx_splat_v4sf (target, element0));
}
@@ -8423,23 +8423,6 @@
   return false;
 }

-/* Helper function for making sure we will make full
-   use of indexed addressing.  */
-
-rtx
-rs6000_force_indexed_or_indirect_mem (rtx x)
-{
-  machine_mode m = GET_MODE (x);
-  if (!indexed_or_indirect_operand (x, m))
-{
-  rtx addr = XEXP (x, 0);
-  addr = force_reg (Pmode, addr);
-  x = replace_equiv_address_nv (x, addr);
-}
-  return x;
-}
-
-
 /* Implement the TARGET_LEGITIMATE_COMBINED_INSN hook.  */

 static bool
@@ -37312,21 +37295,19 @@
   return stack;
 }

-/* Given a memory reference, if it is not a reg or reg+reg addressing, convert
-   to such a form to deal with memory reference instructions like STFIWX that
-   only take reg+reg addressing.  */
+/* Given a memory reference, if it is not a reg or reg+reg addressing,
+   convert to such a form to deal with memory reference instructions
+   like STFIWX and LDBRX that only take reg+reg addressing.  */

 rtx
-rs6000_address_for_fpconvert (rtx x)
+rs6000_force_indexed_or_indirect_mem (rtx x)
 {
-  rtx addr;
+  machine_mode m = GET_MODE (x);

   gcc_assert (MEM_P (x));
-  addr = XEXP (x, 0);
-  if (can_create_pseudo_p ()
-  && ! legitimate_indirect_address_p (addr, reload_completed)
-  && ! legitimate_indexed_address_p (addr, reload_completed))
+  if (can_create_pseudo_p () && !indexed_or_indirect_operand (x, m))
 {
+  rtx addr = XEXP (x, 0);
   if (GET_CODE (addr) == PRE_INC || GET_CODE (addr) == PRE_DEC)
{
  rtx reg = XEXP (addr, 0);
@@ -37346,7 +37327,7 @@
  addr = reg;
}

-  x = replace_equiv_address (x, copy_addr_to_reg (addr));
+  x = replace_equiv_address (x, force_reg (Pmode, addr));
 }

   return x;
Index: gcc/config/rs6000/rs6000.md
===
--- gcc/config/rs6000/rs6000.md (revision 265637)
+++ gcc/config/rs6000/rs6000.md (working copy)
@@ -5225,7 +5225,7 @@
tmp = gen_reg_rtx (DImode);
   if (MEM_P (src))
{
- src = rs600

Re: [PATCH] Verify that last argument of __builtin_expect_with_probability is a real cst (PR c/87811).

2018-11-01 Thread Martin Liška
On 11/1/18 1:15 PM, Jakub Jelinek wrote:
> On Thu, Nov 01, 2018 at 01:09:16PM +0100, Martin Liška wrote:
>> -range 0.0 to 1.0, inclusive.
>> +range 0.0 to 1.0, inclusive.  The @var{probability} argument must be
>> +a compiler time constant.
> 
> When you say must, I think error_at should be used rather than warning_at.
> If others disagree I'm open for leaving it as is.

Error is fine for me as well.

> 
>> @@ -2474,6 +2481,11 @@ expr_expected_value_1 (tree type, tree op0, enum 
>> tree_code code,
>>*predictor = PRED_BUILTIN_EXPECT_WITH_PROBABILITY;
>>*probability = probi;
>>  }
>> +  else
>> +  warning_at (gimple_location (def), 0,
>> +  "probability argument %qE must be a in the "
>> +  "range 0.0 to 1.0", prob);
> 
> Wrong indentation.
> 
> And, no diagnostics for -O0 (which should also be covered by a testcase).

Test for that added.

> 
>> +/* { dg-options "-O2 -fdump-tree-profile_estimate -frounding-math" } */
> 
> Why the -frounding-math options? 

I remember I had some issue with:
  tree r = fold_build2_initializer_loc (UNKNOWN_LOCATION,
MULT_EXPR, t, prob, 
base);

on targets with a non-IEEE floating point arithmetics (s390?).

 I think test
> coverage should handle both that and when that option is not used
> if that option makes any difference.

It will eventually pop up if we install new tests w/o rounding math.

> 
>   Jakub
> 


Martin
>From 7e0834a2ebe1a3fb83304197a843dca63332bc78 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Tue, 30 Oct 2018 14:01:59 +0100
Subject: [PATCH] Verify that last argument of
 __builtin_expect_with_probability is a real cst (PR c/87811).

gcc/ChangeLog:

2018-10-30  Martin Liska  

	PR c/87811
	* predict.c (expr_expected_value_1): Verify
	that last argument is a real constants and emit
	error.

gcc/testsuite/ChangeLog:

2018-10-30  Martin Liska  

	PR c/87811
	* gcc.dg/pr87811.c: New test.
	* gcc.dg/pr87811-2.c: Likewise.
	* gcc.dg/pr87811-3.c: Likewise.

gcc/ChangeLog:

2018-10-30  Martin Liska  

	* doc/extend.texi: Update constrain about the last argument
	of __builtin_expect_with_probability.
---
 gcc/doc/extend.texi  |  3 ++-
 gcc/predict.c| 12 
 gcc/testsuite/gcc.dg/pr87811-2.c | 13 +
 gcc/testsuite/gcc.dg/pr87811-3.c | 11 +++
 gcc/testsuite/gcc.dg/pr87811.c   | 13 +
 5 files changed, 51 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr87811-2.c
 create mode 100644 gcc/testsuite/gcc.dg/pr87811-3.c
 create mode 100644 gcc/testsuite/gcc.dg/pr87811.c

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index e2b9ee11a54..3dabd486dbf 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -12046,7 +12046,8 @@ when testing pointer or floating-point values.
 This function has the same semantics as @code{__builtin_expect},
 but the caller provides the expected probability that @var{exp} == @var{c}.
 The last argument, @var{probability}, is a floating-point value in the
-range 0.0 to 1.0, inclusive.
+range 0.0 to 1.0, inclusive.  The @var{probability} argument must be
+a compiler time constant.
 @end deftypefn
 
 @deftypefn {Built-in Function} void __builtin_trap (void)
diff --git a/gcc/predict.c b/gcc/predict.c
index ab2dc8ed031..80a8d6846f7 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -2467,6 +2467,13 @@ expr_expected_value_1 (tree type, tree op0, enum tree_code code,
 		  base = build_real_from_int_cst (t, base);
 		  tree r = fold_build2_initializer_loc (UNKNOWN_LOCATION,
 			MULT_EXPR, t, prob, base);
+		  if (TREE_CODE (r) != REAL_CST)
+		{
+		  error_at (gimple_location (def),
+"probability argument %qE must be a compile "
+"time constant", prob);
+		  return NULL;
+		}
 		  HOST_WIDE_INT probi
 		= real_to_integer (TREE_REAL_CST_PTR (r));
 		  if (probi >= 0 && probi <= REG_BR_PROB_BASE)
@@ -2474,6 +2481,11 @@ expr_expected_value_1 (tree type, tree op0, enum tree_code code,
 		  *predictor = PRED_BUILTIN_EXPECT_WITH_PROBABILITY;
 		  *probability = probi;
 		}
+		  else
+		error_at (gimple_location (def),
+			  "probability argument %qE must be a in the "
+			  "range 0.0 to 1.0", prob);
+
 		  return gimple_call_arg (def, 1);
 		}
 
diff --git a/gcc/testsuite/gcc.dg/pr87811-2.c b/gcc/testsuite/gcc.dg/pr87811-2.c
new file mode 100644
index 000..aa30ddff47b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr87811-2.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-profile_estimate" } */
+
+void bar (void);
+
+void
+foo (int i)
+{
+  if (__builtin_expect_with_probability (i, 0, 2.0f)) /* { dg-error "probability argument .* must be a in the range 0\\\.0 to 1\\\.0" } */
+bar ();
+}
+
+/* { dg-final { scan-tree-dump-not "__builtin_expect_with_probability h

Re: [PATCH] Fix UB in store-merging or bswap opt (PR tree-optimization/87826)

2018-11-01 Thread Richard Biener
On November 1, 2018 10:14:13 AM GMT+01:00, Jakub Jelinek  
wrote:
>Hi!
>
>When compiling code with UB shifts/rotates where the shift count is out
>of
>range constant, the store-merging and bswap opts will invoke UB in the
>compiler too.
>The following patch prevents that.
>
>Bootstrapped/regtested on x86_64-linux and i686-linux, ok for
>trunk/8.x?

OK. 

Richard. 

>2018-11-01  Jakub Jelinek  
>
>   PR tree-optimization/87826
>   * gimple-ssa-store-merging.c (do_shift_rotate): Punt if count is
>   negative or larger or equal to type's precision.
>
>   * gcc.dg/pr87826.c: New test.
>
>--- gcc/gimple-ssa-store-merging.c.jj  2018-10-23 10:13:25.199876583
>+0200
>+++ gcc/gimple-ssa-store-merging.c 2018-10-31 11:07:50.961296026 +0100
>@@ -262,7 +262,9 @@ do_shift_rotate (enum tree_code code,
>   int i, size = TYPE_PRECISION (n->type) / BITS_PER_UNIT;
>   unsigned head_marker;
> 
>-  if (count % BITS_PER_UNIT != 0)
>+  if (count < 0
>+  || count >= TYPE_PRECISION (n->type)
>+  || count % BITS_PER_UNIT != 0)
> return false;
>   count = (count / BITS_PER_UNIT) * BITS_PER_MARKER;
> 
>--- gcc/testsuite/gcc.dg/pr87826.c.jj  2018-10-31 11:08:56.907209723
>+0100
>+++ gcc/testsuite/gcc.dg/pr87826.c 2018-10-31 11:25:48.078579206 +0100
>@@ -0,0 +1,13 @@
>+/* PR tree-optimization/87826 */
>+/* { dg-do compile } */
>+/* { dg-options "-O3 -w" } */
>+
>+int c;
>+
>+void
>+foo (int *b)
>+{
>+  int e;
>+  for (e = 0; e < 16; ++e)
>+b[e] = c >> e * 8;
>+}
>
>   Jakub



Re: [PATCH] Verify that last argument of __builtin_expect_with_probability is a real cst (PR c/87811).

2018-11-01 Thread Jakub Jelinek
On Thu, Nov 01, 2018 at 01:09:16PM +0100, Martin Liška wrote:
> -range 0.0 to 1.0, inclusive.
> +range 0.0 to 1.0, inclusive.  The @var{probability} argument must be
> +a compiler time constant.

When you say must, I think error_at should be used rather than warning_at.
If others disagree I'm open for leaving it as is.

> @@ -2474,6 +2481,11 @@ expr_expected_value_1 (tree type, tree op0, enum 
> tree_code code,
> *predictor = PRED_BUILTIN_EXPECT_WITH_PROBABILITY;
> *probability = probi;
>   }
> +   else
> +   warning_at (gimple_location (def), 0,
> +   "probability argument %qE must be a in the "
> +   "range 0.0 to 1.0", prob);

Wrong indentation.

And, no diagnostics for -O0 (which should also be covered by a testcase).

> +/* { dg-options "-O2 -fdump-tree-profile_estimate -frounding-math" } */

Why the -frounding-math options?  I think test
coverage should handle both that and when that option is not used
if that option makes any difference.

Jakub


Re: [PATCH] Verify that last argument of __builtin_expect_with_probability is a real cst (PR c/87811).

2018-11-01 Thread Martin Liška
On 10/31/18 11:17 AM, Jakub Jelinek wrote:
> On Wed, Oct 31, 2018 at 11:04:32AM +0100, Martin Liška wrote:
>> Hi.
>>
>> As Jakub pointed out we should not ICE when last argument
>> of __builtin_expect_with_probability is not a real cst.
>> Plus I documented the behavior.
> 
> That is not what you've implemented.  The documentation says that
> it must be a compile time constant, but nothing enforces it, just silently
> ignores it.  So, either diagnose it at the time when
> __builtin_expect_with_probability is removed from the IL, i.e.
> the code you've touched? and expand_builtin_expect_with_probability
> and the argument would be really a late constant (constant after
> inlining and optimizations), or diagnose it in fold_builtin_expect
> and replace with the argument at that point.  And, please diagnose also the
> cases where the probability is not >= 0.0 and <= 1.0.

I provided 2 warnings for both of these situations.

>>  * doc/extend.texi: Update constrain about the last arguemnt
> 
> s/arguemnt/argument/

Fixed.

New patch survives regression tests on x86_64-linux-gnu.

Martin

> 
>   Jakub
> 

>From bae9e3abeeea9b4e2dcde8c1581efaaffd800899 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Tue, 30 Oct 2018 14:01:59 +0100
Subject: [PATCH] Verify that last argument of
 __builtin_expect_with_probability is a real cst (PR c/87811).

gcc/ChangeLog:

2018-10-30  Martin Liska  

	PR c/87811
	* predict.c (expr_expected_value_1): Verify
	that last argument is a real constants.

gcc/testsuite/ChangeLog:

2018-10-30  Martin Liska  

	PR c/87811
	* gcc.dg/pr87811.c: New test.
	* gcc.dg/pr87811-2.c: Likewise.

gcc/ChangeLog:

2018-10-30  Martin Liska  

	* doc/extend.texi: Update constrain about the last argument
	of __builtin_expect_with_probability.
---
 gcc/doc/extend.texi  |  3 ++-
 gcc/predict.c| 12 
 gcc/testsuite/gcc.dg/pr87811-2.c | 13 +
 gcc/testsuite/gcc.dg/pr87811.c   | 13 +
 4 files changed, 40 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr87811-2.c
 create mode 100644 gcc/testsuite/gcc.dg/pr87811.c

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index e2b9ee11a54..3dabd486dbf 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -12046,7 +12046,8 @@ when testing pointer or floating-point values.
 This function has the same semantics as @code{__builtin_expect},
 but the caller provides the expected probability that @var{exp} == @var{c}.
 The last argument, @var{probability}, is a floating-point value in the
-range 0.0 to 1.0, inclusive.
+range 0.0 to 1.0, inclusive.  The @var{probability} argument must be
+a compiler time constant.
 @end deftypefn
 
 @deftypefn {Built-in Function} void __builtin_trap (void)
diff --git a/gcc/predict.c b/gcc/predict.c
index ab2dc8ed031..43621653fee 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -2467,6 +2467,13 @@ expr_expected_value_1 (tree type, tree op0, enum tree_code code,
 		  base = build_real_from_int_cst (t, base);
 		  tree r = fold_build2_initializer_loc (UNKNOWN_LOCATION,
 			MULT_EXPR, t, prob, base);
+		  if (TREE_CODE (r) != REAL_CST)
+		{
+		  warning_at (gimple_location (def), 0,
+  "probability argument %qE must be a compile "
+  "time constant", prob);
+		  return NULL;
+		}
 		  HOST_WIDE_INT probi
 		= real_to_integer (TREE_REAL_CST_PTR (r));
 		  if (probi >= 0 && probi <= REG_BR_PROB_BASE)
@@ -2474,6 +2481,11 @@ expr_expected_value_1 (tree type, tree op0, enum tree_code code,
 		  *predictor = PRED_BUILTIN_EXPECT_WITH_PROBABILITY;
 		  *probability = probi;
 		}
+		  else
+		  warning_at (gimple_location (def), 0,
+  "probability argument %qE must be a in the "
+  "range 0.0 to 1.0", prob);
+
 		  return gimple_call_arg (def, 1);
 		}
 
diff --git a/gcc/testsuite/gcc.dg/pr87811-2.c b/gcc/testsuite/gcc.dg/pr87811-2.c
new file mode 100644
index 000..27d910c9305
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr87811-2.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-profile_estimate -frounding-math" } */
+
+void bar (void);
+
+void
+foo (int i)
+{
+  if (__builtin_expect_with_probability (i, 0, 2.0f)) /* { dg-warning "probability argument .* must be a in the range 0\\\.0 to 1\\\.0" } */
+bar ();
+}
+
+/* { dg-final { scan-tree-dump-not "__builtin_expect_with_probability heuristics of edge" "profile_estimate"} } */
diff --git a/gcc/testsuite/gcc.dg/pr87811.c b/gcc/testsuite/gcc.dg/pr87811.c
new file mode 100644
index 000..18e5c0d97db
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr87811.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-profile_estimate -frounding-math" } */
+
+void bar (void);
+
+void
+foo (int i, double d)
+{
+  if (__builtin_expect_with_probability (i, 0, d)) /* { dg-warning "probability argument .d. must be a compile time constant" } */
+bar ();
+}
+
+/* { dg-final { scan-tree-dump-not "__builtin

Re: hash-table violation in gcc/cp/pt.c

2018-11-01 Thread Martin Liška
I created PR87847 for that.

Martin


[fortran, patch, committed] Adjust error message

2018-11-01 Thread Thomas Koenig

Hello world,

I just adjusted the error message for BIND(C) functions which
return strings of length > 1.  I just used the suggestion from
the PR.  Committed as obvious and simple (although I managed
to use up three revisions to do it right :-)

Regards

Thomas

2018-11-01  Thomas Koenig  

PR fortran/46020
* decl.c (verify_bind_c_sym): Improve error message.

2018-11-01  Thomas Koenig  

PR fortran/46020
* gfortran.dg/bind_c_usage_7.f90: Adjust error message.
* gfortran.dg/bind_c_usage_32.f90: New test.
Index: decl.c
===
--- decl.c	(Revision 265502)
+++ decl.c	(Arbeitskopie)
@@ -5647,8 +5647,8 @@ verify_bind_c_sym (gfc_symbol *tmp_sym, gfc_typesp
 	if (tmp_sym->ts.u.cl == NULL || tmp_sym->ts.u.cl->length == NULL
 	|| tmp_sym->ts.u.cl->length->expr_type != EXPR_CONSTANT
 	|| mpz_cmp_si (tmp_sym->ts.u.cl->length->value.integer, 1) != 0)
-	  gfc_error ("Return type of BIND(C) function %qs at %L cannot "
-			 "be a character string", tmp_sym->name,
+	  gfc_error ("Return type of BIND(C) function %qs of character "
+		 "type at %L must have length 1 ", tmp_sym->name,
 			 &(tmp_sym->declared_at));
 }
 
Index: bind_c_usage_7.f03
===
--- bind_c_usage_7.f03	(Revision 265715)
+++ bind_c_usage_7.f03	(Arbeitskopie)
@@ -7,7 +7,7 @@ contains
 integer(c_int) :: bar(5)
   end function bar
 
-  function my_string_func() bind(c) ! { dg-error "cannot be a character string" }
+  function my_string_func() bind(c) ! { dg-error "must have length 1" }
 character(kind=c_char, len=10) :: my_string_func
 my_string_func = 'my_string' // C_NULL_CHAR
   end function my_string_func
Index: bind_c_usage_32.f90
===
--- bind_c_usage_32.f90	(nicht existent)
+++ bind_c_usage_32.f90	(Revision 265717)
@@ -0,0 +1,13 @@
+! { dg-do compile }
+! PR 46020 - check for clear error message
+! { dg-options "" }
+FUNCTION F_X(A) bind(c,name='F_X') ! { dg-error "must have length 1" }
+   CHARACTER*(*) F_X
+END FUNCTION
+
+
+FUNCTION F_Y(A) bind(c,name='F_Y') ! { dg-error "must have length 1" }
+   CHARACTER*(2) F_Y
+END FUNCTION
+
+


Re: [PATCH][BINUTILS][AARCH64] Add support for pointer authentication B key

2018-11-01 Thread Sam Tebbs
On 11/01/2018 11:56 AM, Sam Tebbs wrote:

> Hi all,
>
> Armv8.3-A has another key used in pointer authentication called the B-key 
> (other
> than the A-key that is already supported). In order for stack unwinders to 
> work
> it is necessary to be able to identify frames that have been signed with the
> B-key rather than the A-key and it was felt that keeping this as an 
> augmentation
> character in the CIE was the best bet. The DWARF extensions for ARM therefore
> propose to add a new augmentation character 'B' to the CIE augmentation string
> and the corresponding cfi directive ".cfi_b_key_frame". I've made the relevant
> changes to GAS and LD to add support for B-key unwinding, which required
> modifying LD to check for 'B' in the augmentation string, adding the
> ".cfi_b_key_frame" directive to GAS and adding a "pauth_key" field to GAS's
> fde_entry and cie_entry structs.
>
> The pointer authentication instructions will behave as NOPs on architectures
> that don't support them, and so a check for the architecture being assembled
> for is not necessary since there will be no behavioural difference between
> augmentation strings with and without the 'B' character on such architectures.
>
> Built on aarch64-linux-gnu and aarch64-none-elf, and tested on 
> aarch64-none-elf
> with no regressions. This patch has been tested with the corresponding patch
> that enables B-key support in GCC.
>
> OK for trunk?
>
> bfd/
> 2018-11-01  Sam Tebbs
>
>   * elf-eh-frame.c (_bfd_elf_parse_eh_frame): Add check for 'B'.
>
> gas/
> 2018-11-01  Sam Tebbs
>
>   * dw2gencfi.c (struct cie_entry): Add pauth_key field.
>   (alloc_fde_entry): Set pauth_key to AARCH64_PAUTH_KEY_A by default.
>   (output_cie): Output 'B' if pauth_key == AARCH64_PAUTH_KEY_B.
>   (select_cie_for_fde): Add check for pauth_key. Set cie's pauth_key to
>   fde's pauth_key.
>   (frch_cfi_data, cfa_save_data): Move to dwgencfi.h.
>   * config/tc-aarch64.c (dot_cfi_b_key_frame): Declare.
>   (md_pseudo_table): Add "cfi_b_key_frame".
>   * dw2gencfi.h (pointer_auth_key): Define.
>   (struct fde_entry): Add pauth_key field.
>   (frch_cfi_data, cfa_save_data): Move from dwgencfi.c.
>
> gas/doc/
> 2018-11-01  Sam Tebbs
>
>   * c-aarch64.texi (.cfi_b_key_frame): Add documentation.
>
> gas/testsuite
> 2018-11-01  Sam Tebbs
>
>   * gas/aarch64/(pac_ab_key.d, pac_ab_key.s): New file.
>

Apologies all, this was sent to the wrong mailing list.


Re: hash-table violation in cselib.c

2018-11-01 Thread Martin Liška
I created PR87845 for that.

Martin


[PATCH][BINUTILS][AARCH64] Add support for pointer authentication B key

2018-11-01 Thread Sam Tebbs
Hi all,

Armv8.3-A has another key used in pointer authentication called the B-key (other
than the A-key that is already supported). In order for stack unwinders to work
it is necessary to be able to identify frames that have been signed with the
B-key rather than the A-key and it was felt that keeping this as an augmentation
character in the CIE was the best bet. The DWARF extensions for ARM therefore
propose to add a new augmentation character 'B' to the CIE augmentation string
and the corresponding cfi directive ".cfi_b_key_frame". I've made the relevant
changes to GAS and LD to add support for B-key unwinding, which required
modifying LD to check for 'B' in the augmentation string, adding the
".cfi_b_key_frame" directive to GAS and adding a "pauth_key" field to GAS's
fde_entry and cie_entry structs.

The pointer authentication instructions will behave as NOPs on architectures
that don't support them, and so a check for the architecture being assembled
for is not necessary since there will be no behavioural difference between
augmentation strings with and without the 'B' character on such architectures.

Built on aarch64-linux-gnu and aarch64-none-elf, and tested on aarch64-none-elf
with no regressions. This patch has been tested with the corresponding patch
that enables B-key support in GCC.

OK for trunk?

bfd/
2018-11-01  Sam Tebbs

* elf-eh-frame.c (_bfd_elf_parse_eh_frame): Add check for 'B'.

gas/
2018-11-01  Sam Tebbs

* dw2gencfi.c (struct cie_entry): Add pauth_key field.
(alloc_fde_entry): Set pauth_key to AARCH64_PAUTH_KEY_A by default.
(output_cie): Output 'B' if pauth_key == AARCH64_PAUTH_KEY_B.
(select_cie_for_fde): Add check for pauth_key. Set cie's pauth_key to
fde's pauth_key.
(frch_cfi_data, cfa_save_data): Move to dwgencfi.h.
* config/tc-aarch64.c (dot_cfi_b_key_frame): Declare.
(md_pseudo_table): Add "cfi_b_key_frame".
* dw2gencfi.h (pointer_auth_key): Define.
(struct fde_entry): Add pauth_key field.
(frch_cfi_data, cfa_save_data): Move from dwgencfi.c.

gas/doc/
2018-11-01  Sam Tebbs

* c-aarch64.texi (.cfi_b_key_frame): Add documentation.

gas/testsuite
2018-11-01  Sam Tebbs

* gas/aarch64/(pac_ab_key.d, pac_ab_key.s): New file.

diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c
index 12f06ef9baa150cf460b451dad9cacd37116b19c..b76a657709f94b64a21bd458aed7f83304bca0dd 100644
--- a/bfd/elf-eh-frame.c
+++ b/bfd/elf-eh-frame.c
@@ -797,6 +797,8 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info,
 	  while (*aug != '\0')
 		switch (*aug++)
 		  {
+		  case 'B':
+		break;
 		  case 'L':
 		REQUIRE (read_byte (&buf, end, &cie->lsda_encoding));
 		ENSURE_NO_RELOCS (buf);
diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index 085ffa26f0e4594fe97b50d19d79e27f742f34e6..e0861512fe5204f1cefcd1e7583f3c55c1be4b10 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -1992,6 +1992,14 @@ s_aarch64_inst (int ignored ATTRIBUTE_UNUSED)
   demand_empty_rest_of_line ();
 }
 
+static void
+s_aarch64_cfi_b_key_frame (int ignored ATTRIBUTE_UNUSED)
+{
+  demand_empty_rest_of_line ();
+  struct fde_entry *fde = frchain_now->frch_cfi_data->cur_fde_data;
+  fde->pauth_key = AARCH64_PAUTH_KEY_B;
+}
+
 #ifdef OBJ_ELF
 /* Emit BFD_RELOC_AARCH64_TLSDESC_ADD on the next ADD instruction.  */
 
@@ -2066,6 +2074,7 @@ const pseudo_typeS md_pseudo_table[] = {
   {"arch", s_aarch64_arch, 0},
   {"arch_extension", s_aarch64_arch_extension, 0},
   {"inst", s_aarch64_inst, 0},
+  {"cfi_b_key_frame", s_aarch64_cfi_b_key_frame, 0},
 #ifdef OBJ_ELF
   {"tlsdescadd", s_tlsdescadd, 0},
   {"tlsdesccall", s_tlsdesccall, 0},
diff --git a/gas/doc/c-aarch64.texi b/gas/doc/c-aarch64.texi
index b659b8ba5971b964fbdf3357c97093471227db67..26c68efc8f522d9d4379a0ab61073d6839bc9b28 100644
--- a/gas/doc/c-aarch64.texi
+++ b/gas/doc/c-aarch64.texi
@@ -424,6 +424,14 @@ as the @code{.dword} directive.
 @c YY
 @c ZZ
 
+@cindex @code{.cfi_b_key_frame} directive, AArch64
+@item	@code{.cfi_b_key_frame}
+The @code{.cfi_b_key_frame} directive inserts a 'B' character into the CIE
+corresponding to the current frame's FDE, meaning that its return address has
+been signed with the B-key.  If two frames are signed with differing keys then
+they will not share the same CIE.  This information is intended to be used by
+the stack unwinder in order to properly authenticate return addresses.
+
 @end table
 
 @node AArch64 Opcodes
diff --git a/gas/dw2gencfi.h b/gas/dw2gencfi.h
index cf534b477696eb5f718b47fdf2bb55d89beafec2..2b1362a2bb02161e8b9e6c8b781e38f39fd319d8 100644
--- a/gas/dw2gencfi.h
+++ b/gas/dw2gencfi.h
@@ -135,6 +135,27 @@ enum {
   EH_COMPACT_HAS_LSDA
 };
 
+enum pointer_auth_key {
+  AARCH64_PAUTH_KEY_A,
+  AARCH64_PAUTH_KEY_B
+};
+
+/* Stack of old CFI data, for save/restore.  */
+struct cfa_save_data
+{
+  struct cfa_save_data 

Patches for gcc/fortran and libgfortran need to be discussed and approved on fortran mailing list

2018-11-01 Thread Thomas Koenig

Hi,

a gentle reminder: Patches which touch gcc/fortran or libgfortran need
to be discussed on the fortran mailing list and approved by a reviewer.

There have been a couple of commits recently where this wasn't followed,
please remember to do so in the future.

Regards

Thomasa


Re: [PATCH] Fix simd.d/compilable.d tests on i686-linux (PR d/87824)

2018-11-01 Thread Iain Buclaw
On Thu, 1 Nov 2018 at 11:37, Jakub Jelinek  wrote:
>
> Hi!
>
> These two tests FAIL on i686-linux, because of extra warnings:
> /home/jakub/src/gcc/gcc/testsuite/gdc.dg/compilable.d:441:6: warning: MMX 
> vector return without MMX enabled changes the ABI [-Wpsabi]
> /home/jakub/src/gcc/gcc/testsuite/gdc.dg/simd.d:1138:8: warning: SSE vector 
> return without SSE enabled changes the ABI [-Wpsabi]
> /home/jakub/src/gcc/gcc/testsuite/gdc.dg/simd.d:1138:8: warning: SSE vector 
> argument without SSE enabled changes the ABI [-Wpsabi]
> The standard way to get around this is by adding -Wno-psabi option
> that disables these warnings.
>
> The following patch makes -Wno-psabi recognized by the D compiler and
> changes the two tests.
>
> Tested on i686-linux, ok for trunk?
>
> Note, other parts of that PR are not fixed.
>
> 2018-11-01  Jakub Jelinek  
>
> PR d/87824
> * lang.opt (Wpsabi): New option.
>
> * gdc.dg/simd.d: Add -Wno-psabi.
> * gdc.dg/compilable.d: Likewise.
>
> --- gcc/d/lang.opt.jj   2018-11-01 07:43:33.760147379 +0100
> +++ gcc/d/lang.opt  2018-11-01 11:30:20.478011972 +0100
> @@ -130,6 +130,10 @@ Werror
>  D
>  ; Documented in common.opt
>
> +Wpsabi
> +D
> +; Documented in C
> +
>  Wspeculative
>  D
>  Warn from speculative compiles such as __traits(compiles).
> --- gcc/testsuite/gdc.dg/simd.d.jj  2018-11-01 07:43:34.568134010 +0100
> +++ gcc/testsuite/gdc.dg/simd.d 2018-11-01 11:25:14.894038430 +0100
> @@ -1,3 +1,4 @@
> +// { dg-options "-Wno-psabi" }
>  // { dg-do run { target hw } }
>  import core.simd;
>  import core.stdc.string;
> --- gcc/testsuite/gdc.dg/compilable.d.jj2018-11-01 07:43:34.562134109 
> +0100
> +++ gcc/testsuite/gdc.dg/compilable.d   2018-11-01 11:25:01.712255255 +0100
> @@ -1,4 +1,4 @@
> -// { dg-options "-I $srcdir/gdc.dg -I $srcdir/gdc.dg/imports" }
> +// { dg-options "-I $srcdir/gdc.dg -I $srcdir/gdc.dg/imports -Wno-psabi" }
>  // { dg-additional-sources "imports/gdc27.d imports/gdc231.d" }
>  // { dg-do compile }
>
>

OK. Thanks.

-- 
Iain


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

2018-11-01 Thread JonY
On 10/31/2018 10:39 PM, Alexandre Oliva wrote:
> On Oct 12, 2018, Alexandre Oliva  wrote:
> 
>>  * config/i386/mingw32.h (LINK_SPEC_LARGE_ADDR_AWARE): Define,
>>  based on MINGW_DEFAULT_LARGE_ADDR_AWARE.
>>  (LINK_SPEC): Insert it.
>>  * config/i386/mingw-264.h: Likewise.
> ^ s/2/w/, fixing...
> 
> Now, it occurred to me that it is possible for biarch64.h to be
> included, thus enabling 64-bit mode even by default, without including
> mingw-w64.h.  I had assumed in my patch that this was not supposed to
> happen, but configuring with --target=x86_64-mingw32 shows it does
> happen, and such a toolchain may (after my patch) pass
> --large-address-aware to the linker, even when linking -m64 binaries.
> 
> Is that target configuration really supposed to be different from
> x86_64-w64-mingw32 (or however else the w64 configuration is supposed to
> be spelled), or should x86_64-mingw32 also use mingw-w64.h so that
> they're equivalent?
> 
> It seems to me that we need a further patch like this:
> 
> diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h
> index c9d8a7a31f30..848eb8430b30 100644
> --- a/gcc/config/i386/mingw32.h
> +++ b/gcc/config/i386/mingw32.h
> @@ -114,11 +114,17 @@ along with GCC; see the file COPYING3.  If not see
>  #define SUBTARGET_EXTRA_SPECS
> \
>{ "shared_libgcc_undefs", SHARED_LIBGCC_UNDEFS_SPEC }
>  
> -#if MINGW_DEFAULT_LARGE_ADDR_AWARE
> +#if ! MINGW_DEFAULT_LARGE_ADDR_AWARE
> +# define LINK_SPEC_LARGE_ADDR_AWARE ""
> +#elif ! TARGET_BI_ARCH
>  # define LINK_SPEC_LARGE_ADDR_AWARE \
>"%{!shared:%{!mdll:--large-address-aware}}"
> +#elif TARGET_64BIT_DEFAULT
> +# define LINK_SPEC_LARGE_ADDR_AWARE \
> +  "%{!shared:%{!mdll:%{m32:--large-address-aware}}}"
>  #else
> -# define LINK_SPEC_LARGE_ADDR_AWARE ""
> +# define LINK_SPEC_LARGE_ADDR_AWARE \
> +  "%{!shared:%{!mdll:%{!m64:--large-address-aware}}}"
>  #endif
>  
>  #define LINK_SPEC "%{mwindows:--subsystem windows} \
> 
> But then, even this wouldn't necessarily do the right thing if e.g.
> biarchx32.h is in effect.  Is that even possible?
> 
> Or can we just leave mingw32.h as is, considering that (AFAIK) -m64 *is*
> --large-address-aware, it just has that enabled by default?
> 

Looks like it causes an error on 64bit:
/usr/libexec/gcc/x86_64-w64-mingw32/ld: unrecognized option
'--large-address-aware'

So it'll need to be excluded for x86_64.



signature.asc
Description: OpenPGP digital signature


[PATCH] Fix simd.d/compilable.d tests on i686-linux (PR d/87824)

2018-11-01 Thread Jakub Jelinek
Hi!

These two tests FAIL on i686-linux, because of extra warnings:
/home/jakub/src/gcc/gcc/testsuite/gdc.dg/compilable.d:441:6: warning: MMX 
vector return without MMX enabled changes the ABI [-Wpsabi]
/home/jakub/src/gcc/gcc/testsuite/gdc.dg/simd.d:1138:8: warning: SSE vector 
return without SSE enabled changes the ABI [-Wpsabi]
/home/jakub/src/gcc/gcc/testsuite/gdc.dg/simd.d:1138:8: warning: SSE vector 
argument without SSE enabled changes the ABI [-Wpsabi]
The standard way to get around this is by adding -Wno-psabi option
that disables these warnings.

The following patch makes -Wno-psabi recognized by the D compiler and
changes the two tests.

Tested on i686-linux, ok for trunk?

Note, other parts of that PR are not fixed.

2018-11-01  Jakub Jelinek  

PR d/87824
* lang.opt (Wpsabi): New option.

* gdc.dg/simd.d: Add -Wno-psabi.
* gdc.dg/compilable.d: Likewise.

--- gcc/d/lang.opt.jj   2018-11-01 07:43:33.760147379 +0100
+++ gcc/d/lang.opt  2018-11-01 11:30:20.478011972 +0100
@@ -130,6 +130,10 @@ Werror
 D
 ; Documented in common.opt
 
+Wpsabi
+D
+; Documented in C
+
 Wspeculative
 D
 Warn from speculative compiles such as __traits(compiles).
--- gcc/testsuite/gdc.dg/simd.d.jj  2018-11-01 07:43:34.568134010 +0100
+++ gcc/testsuite/gdc.dg/simd.d 2018-11-01 11:25:14.894038430 +0100
@@ -1,3 +1,4 @@
+// { dg-options "-Wno-psabi" }
 // { dg-do run { target hw } }
 import core.simd;
 import core.stdc.string;
--- gcc/testsuite/gdc.dg/compilable.d.jj2018-11-01 07:43:34.562134109 
+0100
+++ gcc/testsuite/gdc.dg/compilable.d   2018-11-01 11:25:01.712255255 +0100
@@ -1,4 +1,4 @@
-// { dg-options "-I $srcdir/gdc.dg -I $srcdir/gdc.dg/imports" }
+// { dg-options "-I $srcdir/gdc.dg -I $srcdir/gdc.dg/imports -Wno-psabi" }
 // { dg-additional-sources "imports/gdc27.d imports/gdc231.d" }
 // { dg-do compile }
 

Jakub


Re: [PATCH] Remove extra memory allocation of strings.

2018-11-01 Thread Martin Liška
On 10/23/18 3:17 PM, Martin Liška wrote:
> Hello.
> 
> As a follow up patch I would like to remove redundant string allocation
> on string which is not needed in my opinion.
> 
> That bootstrap on aarch64-linux.
> 
> Martin
> 

James may I please remind this small patch?

Thanks,
Martin


Re: [PATCH] Make __PRETTY_FUNCTION__-like functions mergeable string csts (PR c++/64266).

2018-11-01 Thread Martin Liška
On 10/31/18 2:42 AM, Jason Merrill wrote:
> On 10/29/18 9:37 AM, Jason Merrill wrote:
>> On Fri, Oct 26, 2018 at 3:14 AM Martin Liška  wrote:
>>> On 10/24/18 7:24 PM, Jason Merrill wrote:
 On Tue, Oct 23, 2018 at 4:59 AM Martin Liška  wrote:
> However, I still see some minor ICEs, it's probably related to 
> decay_conversion in cp_fname_init:
>
> 1) ./xg++ -B. 
> /home/marxin/Programming/gcc/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-__func__2.C
>
> /home/marxin/Programming/gcc/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-__func__2.C:6:17:
>  internal compiler error: Segmentation fault
> 6 | [] { return __func__; }();
>    | ^~~~
> 0x1344568 crash_signal
>  /home/marxin/Programming/gcc/gcc/toplev.c:325
> 0x76bc310f ???
>  
> /usr/src/debug/glibc-2.27-6.1.x86_64/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
> 0x9db134 is_capture_proxy(tree_node*)
>>>
>>> Hi.
>>>

 The problem in both tests is that is_capture_proxy thinks your
 __func__ VAR_DECL with DECL_VALUE_EXPR is a capture proxy, since it is
 neither an anonymous union proxy nor a structured binding.
>>>
>>> I see, however I'm a rookie in area of C++ FE. Would it be solvable this 
>>> problem
>>> with lambdas?
>>>

 The standard says,

 The function-local predefined variable __func__ is defined as if a
 definition of the form
     static const char __func__[] = "function-name ";
 had been provided, where function-name is an implementation-defined
 string. It is unspecified whether such a variable has an address
 distinct from that of any other object in the program.

 So changing the type of __func__ (from array to pointer) still breaks
 conformance.  And we need to keep the type checks from pretty4.C, even
 though the checks for strings being distinct need to go.
>>>
>>> I added following patch which puts back type to const char[] (instead of 
>>> char *)
>>> and I made the variable static. Now I see pretty4.C testcase passing again.
>>> To be honest I'm not convinced about the FE changes, so a help would
>>> be appreciated.
>>
>> OK, I'll poke at it.
> 
> This further patch teaches is_capture_proxy about function-name variables, 
> and changes the handling of __PRETTY_FUNCTION__ in template instantiations to 
> create new variables rather than instantiations.
> 
> The C++ changes are OK with this.
> 

Thank you very much Jason!
There's final version of the patch that I'm going to install.

Martin
>From 077608ee88e277d569851969babe0f2fcf20fbf2 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Thu, 4 Oct 2018 15:34:51 +0200
Subject: [PATCH] Make __PRETTY_FUNCTION__-like functions mergeable string csts
 (PR c++/64266).

gcc/cp/ChangeLog:

2018-10-31  Martin Liska  
	Jason Merrill  

	PR c++/64266
	PR bootstrap/70422
	PR ipa/81277
	* cp-tree.h (DECL_FNAME_P): New macro.
	* decl.c (cp_make_fname_decl): Set DECL_DECLARED_CONSTEXPR_P,
DECL_VALUE_EXPR, DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P.
	(cp_finish_decl):
	* lambda.c (is_capture_proxy): Use DECL_FNAME_P.
	* pt.c (tsubst_expr): Handle DECL_PRETTY_FUNCTION_P.

gcc/testsuite/ChangeLog:

2018-10-31  Martin Liska  
	Jason Merrill  

	PR c++/64266
	PR bootstrap/70422
	PR ipa/81277
	* g++.dg/cpp0x/constexpr-__func__2.C: Make it a compilation
	test.
	* g++.old-deja/g++.ext/pretty4.C: Remove as the run-time
	assumptions are not longer valid.
---
 gcc/cp/cp-tree.h  |  8 ++
 gcc/cp/decl.c | 25 --
 gcc/cp/lambda.c   |  1 +
 gcc/cp/pt.c   | 16 ++--
 .../g++.dg/cpp0x/constexpr-__func__2.C|  7 +-
 gcc/testsuite/g++.old-deja/g++.ext/pretty4.C  | 85 ---
 6 files changed, 36 insertions(+), 106 deletions(-)
 delete mode 100644 gcc/testsuite/g++.old-deja/g++.ext/pretty4.C

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 03e88838cbe..42449f10a48 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3132,6 +3132,14 @@ struct GTY(()) lang_decl {
   (DECL_NAME (NODE) \
&& id_equal (DECL_NAME (NODE), "__PRETTY_FUNCTION__"))
 
+/* For a DECL, true if it is __func__ or similar.  */
+#define DECL_FNAME_P(NODE)	\
+  (VAR_P (NODE) && DECL_NAME (NODE) && DECL_ARTIFICIAL (NODE)	\
+   && DECL_HAS_VALUE_EXPR_P (NODE)\
+   && (id_equal (DECL_NAME (NODE), "__PRETTY_FUNCTION__")	\
+   || id_equal (DECL_NAME (NODE), "__FUNCTION__")		\
+   || id_equal (DECL_NAME (NODE), "__func__")))
+
 /* Nonzero if the variable was declared to be thread-local.
We need a special C++ version of this test because the middle-end
DECL_THREAD_LOCAL_P uses the symtab, so we can't use it for
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 11320b65e71..1cea5262b62 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4465,7 +4465,7 @@ cp_fname_init (const char* name, tree *type_p)
 static tr

[PATCH] Fix UB in store-merging or bswap opt (PR tree-optimization/87826)

2018-11-01 Thread Jakub Jelinek
Hi!

When compiling code with UB shifts/rotates where the shift count is out of
range constant, the store-merging and bswap opts will invoke UB in the
compiler too.
The following patch prevents that.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/8.x?

2018-11-01  Jakub Jelinek  

PR tree-optimization/87826
* gimple-ssa-store-merging.c (do_shift_rotate): Punt if count is
negative or larger or equal to type's precision.

* gcc.dg/pr87826.c: New test.

--- gcc/gimple-ssa-store-merging.c.jj   2018-10-23 10:13:25.199876583 +0200
+++ gcc/gimple-ssa-store-merging.c  2018-10-31 11:07:50.961296026 +0100
@@ -262,7 +262,9 @@ do_shift_rotate (enum tree_code code,
   int i, size = TYPE_PRECISION (n->type) / BITS_PER_UNIT;
   unsigned head_marker;
 
-  if (count % BITS_PER_UNIT != 0)
+  if (count < 0
+  || count >= TYPE_PRECISION (n->type)
+  || count % BITS_PER_UNIT != 0)
 return false;
   count = (count / BITS_PER_UNIT) * BITS_PER_MARKER;
 
--- gcc/testsuite/gcc.dg/pr87826.c.jj   2018-10-31 11:08:56.907209723 +0100
+++ gcc/testsuite/gcc.dg/pr87826.c  2018-10-31 11:25:48.078579206 +0100
@@ -0,0 +1,13 @@
+/* PR tree-optimization/87826 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -w" } */
+
+int c;
+
+void
+foo (int *b)
+{
+  int e;
+  for (e = 0; e < 16; ++e)
+b[e] = c >> e * 8;
+}

Jakub