[C++ Patch] Fix a start_decl location

2019-01-06 Thread Paolo Carlini

Hi,

this was supposed to be very straightforward but required a little more. 
A first draft of the patch exploited DECL_SOURCE_LOCATION but that 
failed when I tested the case of a function already defined in class: at 
that point the location of the decl is that of the in class definition 
itself not that of the wrong redeclaration. Thus the use of 
declarator->id_loc. Tested x86_64-linux.


A final note, about a detail already noticed many other times: the 
location we store in such cases is that of K not that of f, and that 
seems suboptimal to me: in principle we should point to f and possibly 
have the wavy queue of the caret going back to K, at least that's what 
clang does... no idea id David has this kind of tweak in his todo list.


Thanks, Paolo.



/cp
2019-01-06  Paolo Carlini  

* decl.c (start_decl): Improve permerror location.

/testsuite
2019-01-06  Paolo Carlini  

* g++.dg/diagnostic/out-of-class-redeclaration.C: New.
Index: cp/decl.c
===
--- cp/decl.c   (revision 267600)
+++ cp/decl.c   (working copy)
@@ -5202,7 +5202,8 @@ start_decl (const cp_declarator *declarator,
   if (DECL_EXTERNAL (decl) && ! DECL_TEMPLATE_SPECIALIZATION (decl)
  /* Aliases are definitions. */
  && !alias)
-   permerror (input_location, "declaration of %q#D outside of class is not 
definition",
+   permerror (declarator->id_loc,
+  "declaration of %q#D outside of class is not definition",
   decl);
 }
 
Index: testsuite/g++.dg/diagnostic/out-of-class-redeclaration.C
===
--- testsuite/g++.dg/diagnostic/out-of-class-redeclaration.C(nonexistent)
+++ testsuite/g++.dg/diagnostic/out-of-class-redeclaration.C(working copy)
@@ -0,0 +1,13 @@
+// Adapted from g++.old-deja/g++.law/arm8.C
+
+struct K {
+  void f(int);
+};
+
+void K::f(int);  // { dg-error "6:declaration of .void K::f\\(int\\). outside 
of class" }
+
+struct L {
+  void g(int) {}
+};
+
+void L::g(int);  // { dg-error "6:declaration of .void L::g\\(int\\). outside 
of class" }


Re: [PATCH] accept all C integer types in function parameters referenced by alloc_align (PR 88363)

2019-01-06 Thread Jakub Jelinek
On Tue, Dec 11, 2018 at 01:36:58PM -0700, Martin Sebor wrote:
> --- gcc/testsuite/c-c++-common/attributes-4.c (nonexistent)
> +++ gcc/testsuite/c-c++-common/attributes-4.c (working copy)
> @@ -0,0 +1,47 @@
...
> +ATTR (alloc_align (1)) void* falloc_align_int128 (__int128_t);
...
> +ATTR (alloc_align (1)) void* falloc_size_int128 (__int128_t);

The test FAILs on 32-bit targets which don't have __int128_t type.
As there is no associated diagnostics expected with these, I've just guarded
those with #ifdef __SIZEOF_INT128__, tested on x86_64-linux -m32/-m64
and committed as obvious to trunk:

2019-01-06  Jakub Jelinek  

PR c/88363
* c-c++-common/attributes-4.c (falloc_align_int128,
falloc_size_int128): Guard with #ifdef __SIZEOF_INT128__.

--- gcc/testsuite/c-c++-common/attributes-4.c.jj2019-01-05 
12:06:13.416101609 +0100
+++ gcc/testsuite/c-c++-common/attributes-4.c   2019-01-06 11:23:13.198901344 
+0100
@@ -26,7 +26,9 @@ ATTR (alloc_align (1)) void* falloc_alig
 /* Using an enum might make sense in an API that limits the alignments
it accepts to just the set of the defined enumerators.   */
 ATTR (alloc_align (1)) void* falloc_align_enum (enum A);
+#ifdef __SIZEOF_INT128__
 ATTR (alloc_align (1)) void* falloc_align_int128 (__int128_t);
+#endif
 
 
 ATTR (alloc_align (1)) void* falloc_size_char (char);
@@ -34,7 +36,9 @@ ATTR (alloc_size (1)) void* falloc_size_
 ATTR (alloc_size (1)) void* falloc_size_char32 (char32_t);
 ATTR (alloc_size (1)) void* falloc_size_wchar (wchar_t);
 ATTR (alloc_size (1)) void* falloc_size_enum (enum A);
+#ifdef __SIZEOF_INT128__
 ATTR (alloc_align (1)) void* falloc_size_int128 (__int128_t);
+#endif
 
 
 typedef struct { int i; } S;


Jakub


Re: [PATCH] Add a two value VR comparison to two consecutive PHI args optimization (PR tree-optimization/88676, take 2)

2019-01-06 Thread Jakub Jelinek
On Sat, Jan 05, 2019 at 01:17:47PM +0100, Jakub Jelinek wrote:
> Ok for trunk if it passes bootstrap/regtest?

FYI, it passed bootstrap/regtest on x86_64-linux and i686-linux.

Jakub


[PATCH] Add vec_extract{v32qiv16qi,v16hiv8hi,v8siv4si,v4div2di,v8sfv4sf,v4dfv2df}

2019-01-06 Thread Jakub Jelinek
Hi!

Looking at the output of builtin-convertvector-1.c (f4), this patch changes
the generated code:
vcvttpd2dqy (%rdi), %xmm0
-   vmovdqa %xmm0, %xmm0
vmovaps %xmm0, (%rsi)
-   vzeroupper
ret
The problem is that without vec_extract patterns to extract 128-bit vectors
from 256-bit ones, the expander creates TImode extraction and combine +
simplify-rtx.c isn't able to optimize it out properly due to vector ->
non-vector -> vector mode subregs in there.
We already have vec_extract patterns to extract 256-bit vectors from 512-bit
ones and we have all the vec_extract_{lo,hi}_* named insns even for the
128-bit out of 256-bit vectors, so this patch just makes those available to
the expander.

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

2019-01-06  Jakub Jelinek  

* config/i386/sse.md (vec_extract): Use
V_256_512 iterator instead of V_512 and TARGET_AVX instead of
TARGET_AVX512F as condition.

--- gcc/config/i386/sse.md.jj   2019-01-04 09:56:08.548495229 +0100
+++ gcc/config/i386/sse.md  2019-01-05 21:33:34.057288059 +0100
@@ -8362,9 +8362,9 @@ (define_expand "vec_extract"
   [(match_operand: 0 "nonimmediate_operand")
-   (match_operand:V_512 1 "register_operand")
+   (match_operand:V_256_512 1 "register_operand")
(match_operand 2 "const_0_to_1_operand")]
-  "TARGET_AVX512F"
+  "TARGET_AVX"
 {
   if (INTVAL (operands[2]))
 emit_insn (gen_vec_extract_hi_ (operands[0], operands[1]));

Jakub


*ping* [patch, fortran] Fix PR 88658, wrong type for MAX1 and friends type when simplifying

2019-01-06 Thread Thomas Koenig

Am 02.01.19 um 15:31 schrieb Thomas Koenig:

Hello world,

the attached patch fixes the PR, a regression introduced by r265649,
by special-casing those intrinsics of the min/max family which
need to be special-cased.

This is actually something that had been fixed before (PR 14377),
but at the time, no test case had been committed.

Regression-tested. OK for trunk?

Regards

 Thomas


Ping?


[RFC] Add gcc_assert_implies

2019-01-06 Thread Tom de Vries
Hi,

Comments welcome.

Thanks,
- Tom
[RFC] Add gcc_assert_implies

[ Following up on "Fix bug in simplify_ternary_operation" (
https://gcc.gnu.org/ml/gcc-patches/2017-11/msg01699.html ). ]

The C/C++ languages do not support the implication logical operator a -> b, so
we typically use '!a || b'.  Or, possibly the equivalent but more complicated
'!(a && !b)'.  Both have the convenient property that b is not evaluated if !a.

However, for both forms, the more complex and/or long operands a and b become,
the harder it becomes to understand that there's an implication relationship.

Add a macro gcc_assert_implies(a, b) that allows us to express a top-level
implication relationship in an assert.

The semantics of gcc_assert_implies (a, b) can understood as:
...
  if (a)
gcc_assert (b);
...

[ So an alternative name could be gcc_assert_if, gcc_if_assert or
gcc_cond_assert. ]

Also, using this kind of assert will make it easier to spot that:
...
  gcc_assert_implies (a, b);
  if (a)
{
  ...
}
...
can be simplified into:
...
  if (a)
{
  gcc_assert (b);
  ...
}
...

2019-01-06  Tom de Vries  

	* system.h (gcc_assert_implies): Define.
	* gimple-iterator.c (gsi_insert_seq_nodes_before): Use
	gcc_assert_implies.
	* simplify-rtx.c (simplify_const_relational_operation): Same.

---
 gcc/gimple-iterator.c | 2 +-
 gcc/simplify-rtx.c| 5 ++---
 gcc/system.h  | 2 ++
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/gcc/gimple-iterator.c b/gcc/gimple-iterator.c
index e0e4e123678..2e55ec00c0c 100644
--- a/gcc/gimple-iterator.c
+++ b/gcc/gimple-iterator.c
@@ -119,7 +119,7 @@ gsi_insert_seq_nodes_before (gimple_stmt_iterator *i,
   basic_block bb;
   gimple_seq_node cur = i->ptr;
 
-  gcc_assert (!cur || cur->prev);
+  gcc_assert_implies (cur, cur->prev);
 
   if ((bb = gsi_bb (*i)) != NULL)
 update_bb_for_stmts (first, last, bb);
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 748155a5823..eabe6eeb281 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -5234,9 +5234,8 @@ simplify_const_relational_operation (enum rtx_code code,
   rtx trueop0;
   rtx trueop1;
 
-  gcc_assert (mode != VOIDmode
-	  || (GET_MODE (op0) == VOIDmode
-		  && GET_MODE (op1) == VOIDmode));
+  gcc_assert_implies (mode == VOIDmode,
+		  GET_MODE (op0) == VOIDmode && GET_MODE (op1) == VOIDmode);
 
   /* If op0 is a compare, extract the comparison arguments from it.  */
   if (GET_CODE (op0) == COMPARE && op1 == const0_rtx)
diff --git a/gcc/system.h b/gcc/system.h
index d04f8fd3360..abbb121a8b4 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -748,6 +748,8 @@ extern void fancy_abort (const char *, int, const char *)
 #define gcc_assert(EXPR) ((void)(0 && (EXPR)))
 #endif
 
+#define gcc_assert_implies(EXPR1, EXPR2) gcc_assert (!(EXPR1) || (EXPR2))
+
 #if CHECKING_P
 #define gcc_checking_assert(EXPR) gcc_assert (EXPR)
 #else


Re: *ping* [patch, fortran] Fix PR 88658, wrong type for MAX1 and friends type when simplifying

2019-01-06 Thread Janne Blomqvist
On Sun, Jan 6, 2019 at 12:54 PM Thomas Koenig  wrote:

> Am 02.01.19 um 15:31 schrieb Thomas Koenig:
> > Hello world,
> >
> > the attached patch fixes the PR, a regression introduced by r265649,
> > by special-casing those intrinsics of the min/max family which
> > need to be special-cased.
> >
> > This is actually something that had been fixed before (PR 14377),
> > but at the time, no test case had been committed.
> >
> > Regression-tested. OK for trunk?
> >
> > Regards
> >
> >  Thomas
>
> Ping?
>

Ok, thanks.

-- 
Janne Blomqvist


Backport to GCC 8 branch fix for PIC LTO option merging

2019-01-06 Thread Jan Hubicka
Hi,
I have backported the following patch to merge PIC/PIE options in LTO
wrapper.

Bootstrapped/regtested x86_64-linux

Honza

2019-01-03  Jan Hubicka  
Backport from mainline
2018-08-29  Jan Hubicka  

PR lto/86517
PR lto/88185
* lto-opts.c (lto_write_options): Always stream PIC/PIE mode.
* lto-wrapper.c (merge_and_complain): Fix merging of PIC/PIE.

 
Index: lto-opts.c
===
--- lto-opts.c  (revision 267609)
+++ lto-opts.c  (working copy)
@@ -78,6 +78,21 @@ lto_write_options (void)
   && !global_options.x_flag_openacc)
 append_to_collect_gcc_options (&temporary_obstack, &first_p,
   "-fno-openacc");
+  /* Append PIC/PIE mode because its default depends on target and it is
+ subject of merging in lto-wrapper.  */
+  if (!global_options_set.x_flag_pic && !global_options_set.x_flag_pie)
+{
+   append_to_collect_gcc_options (&temporary_obstack, &first_p,
+ global_options.x_flag_pic == 2
+ ? "-fPIC"
+ : global_options.x_flag_pic == 1
+ ? "-fpic"
+ : global_options.x_flag_pie == 2
+ ? "-fPIE"
+ : global_options.x_flag_pie == 1
+ ? "-fpie"
+ : "-fno-pie");
+}
 
   /* Append options from target hook and store them to offload_lto section.  */
   if (lto_stream_offload_p)
Index: lto-wrapper.c
===
--- lto-wrapper.c   (revision 267609)
+++ lto-wrapper.c   (working copy)
@@ -408,6 +408,11 @@ merge_and_complain (struct cl_decoded_op
  It is a common mistake to mix few -fPIC compiled objects into otherwise
  non-PIC code.  We do not want to build everything with PIC then.
 
+ Similarly we merge PIE options, however in addition we keep
+  -fPIC + -fPIE = -fPIE
+  -fpic + -fPIE = -fpie
+  -fPIC/-fpic + -fpie = -fpie
+
  It would be good to warn on mismatches, but it is bit hard to do as
  we do not know what nothing translates to.  */
 
@@ -415,11 +420,38 @@ merge_and_complain (struct cl_decoded_op
 if ((*decoded_options)[j].opt_index == OPT_fPIC
 || (*decoded_options)[j].opt_index == OPT_fpic)
   {
-   if (!pic_option
-   || (pic_option->value > 0) != ((*decoded_options)[j].value > 0))
- remove_option (decoded_options, j, decoded_options_count);
-   else if (pic_option->opt_index == OPT_fPIC
-&& (*decoded_options)[j].opt_index == OPT_fpic)
+   /* -fno-pic in one unit implies -fno-pic everywhere.  */
+   if ((*decoded_options)[j].value == 0)
+ j++;
+   /* If we have no pic option or merge in -fno-pic, we still may turn
+  existing pic/PIC mode into pie/PIE if -fpie/-fPIE is present.  */
+   else if ((pic_option && pic_option->value == 0)
+|| !pic_option)
+ {
+   if (pie_option)
+ {
+   bool big = (*decoded_options)[j].opt_index == OPT_fPIC
+  && pie_option->opt_index == OPT_fPIE;
+   (*decoded_options)[j].opt_index = big ? OPT_fPIE : OPT_fpie;
+   if (pie_option->value)
+ (*decoded_options)[j].canonical_option[0] = big ? "-fPIE" : 
"-fpie";
+   else
+ (*decoded_options)[j].canonical_option[0] = big ? "-fno-pie" 
: "-fno-pie";
+   (*decoded_options)[j].value = pie_option->value;
+   j++;
+ }
+   else if (pic_option)
+ {
+   (*decoded_options)[j] = *pic_option;
+   j++;
+ }
+   /* We do not know if target defaults to pic or not, so just remove
+  option if it is missing in one unit but enabled in other.  */
+   else
+ remove_option (decoded_options, j, decoded_options_count);
+ }
+   else if (pic_option->opt_index == OPT_fpic
+&& (*decoded_options)[j].opt_index == OPT_fPIC)
  {
(*decoded_options)[j] = *pic_option;
j++;
@@ -430,11 +462,42 @@ merge_and_complain (struct cl_decoded_op
else if ((*decoded_options)[j].opt_index == OPT_fPIE
 || (*decoded_options)[j].opt_index == OPT_fpie)
   {
-   if (!pie_option
-   || pie_option->value != (*decoded_options)[j].value)
- remove_option (decoded_options, j, decoded_options_count);
-   else if (pie_option->opt_index == OPT_fPIE
-&& (*decoded_options)[j].opt_index == OPT_fpie)
+   /* -fno-pie in one unit implies -fno-pie everywhere.  */
+   if ((*decoded_options)[j].value == 0)
+ j++;
+   /* If we h

Add forgotten options to -fprofile-use

2019-01-06 Thread Jan Hubicka
Hi,
I have noticed that we now enabled more loop transformations at -O3 but
not for -fprofile-use.  Like loop transforms we already have, they
should be enabled because with profile they should be almost consistent
win.  I have checked that all the passes check profile except for loop
interchange which I guess is Ok since the code size should not increase
in general.

Bootstrapped/regtested x86_64-linux, comitted.

Honza

* opts.c (enable_fdo_optimizations): Enable
version-loops-for-strides, loop-interchange, unrol-and-jam
and tree-loop-distribution.
* invoke.texi: Document newly enabled options.
Index: opts.c
===
--- opts.c  (revision 267601)
+++ opts.c  (working copy)
@@ -1708,10 +1708,18 @@ enable_fdo_optimizations (struct gcc_opt
 opts->x_flag_tree_loop_vectorize = value;
   if (!opts_set->x_flag_tree_slp_vectorize)
 opts->x_flag_tree_slp_vectorize = value;
+  if (!opts_set->x_flag_version_loops_for_strides)
+opts->x_flag_version_loops_for_strides = value;
   if (!opts_set->x_flag_vect_cost_model)
 opts->x_flag_vect_cost_model = VECT_COST_MODEL_DYNAMIC;
   if (!opts_set->x_flag_tree_loop_distribute_patterns)
 opts->x_flag_tree_loop_distribute_patterns = value;
+  if (!opts_set->x_flag_loop_interchange)
+opts->x_flag_loop_interchange = value;
+  if (!opts_set->x_flag_unroll_jam)
+opts->x_flag_unroll_jam = value;
+  if (!opts_set->x_flag_tree_loop_distribution)
+opts->x_flag_tree_loop_distribution = value;
 }
 
 /* -f{,no-}sanitize{,-recover}= suboptions.  */
Index: doc/invoke.texi
===
--- doc/invoke.texi (revision 267603)
+++ doc/invoke.texi (working copy)
@@ -9499,6 +9499,8 @@ DO I = 1, N
D(I) = E(I) * F
 ENDDO
 @end smallexample
+This flag is enabled by default at @option{-O3}.
+It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
 
 @item -ftree-loop-distribute-patterns
 @opindex ftree-loop-distribute-patterns
@@ -9524,6 +9526,8 @@ DO I = 1, N
 ENDDO
 @end smallexample
 and the initialization loop is transformed into a call to memset zero.
+This flag is enabled by default at @option{-O3}.
+It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
 
 @item -floop-interchange
 @opindex floop-interchange
@@ -9544,12 +9548,14 @@ for (int i = 0; i < N; i++)
   c[i][j] = c[i][j] + a[i][k]*b[k][j];
 @end smallexample
 This flag is enabled by default at @option{-O3}.
+It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
 
 @item -floop-unroll-and-jam
 @opindex floop-unroll-and-jam
 Apply unroll and jam transformations on feasible loops.  In a loop
 nest this unrolls the outer loop by some factor and fuses the resulting
 multiple inner loops.  This flag is enabled by default at @option{-O3}.
+It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
 
 @item -ftree-loop-im
 @opindex ftree-loop-im
@@ -10804,6 +10810,8 @@ else
 
 This is particularly useful for assumed-shape arrays in Fortran where
 (for example) it allows better vectorization assuming contiguous accesses.
+This flag is enabled by default at @option{-O3}.
+It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
 
 @item -ffunction-sections
 @itemx -fdata-sections


Re: [PATCH] Export explicit instantiations for C++17 members of std::string

2019-01-06 Thread Rainer Orth
Hi Jonathan,

> The C++17 standard added some new members to std::basic_string, which
> were not previously instantiated in the library. This meant that the
> extern template declarations had to be disabled for C++17 mode. With
> this patch the new members are instantiated in the library and so the
> explicit instantiation declarations can be used for C++17.
>
> The new members added by C++2a are still not exported, and so the
> explicit instantiation declarations are still disabled for C++2a.
>
>   * config/abi/pre/gnu.ver (GLIBCXX_3.4.21): Make patterns less greedy
>   for const member functions of std::basic_string.
>   (GLIBCXX_3.4.26): Export member functions of std::basic_string added
>   in C++17.
>   * include/bits/basic_string.h (basic_string(__sv_wrapper, const A&)):
>   Make non-standard constructor private.
>   [!_GLIBCXX_USE_CXX11_ABI] (basic_string(__sv_wrapper, const A&)):
>   Likewise.
>   * include/bits/basic_string.tcc (std::string, std::wstring): Declare
>   explicit instantiations for C++17 as well as earlier dialects.
>   * src/c++17/Makefile.am: Add new source files.
>   * src/c++17/Makefile.in: Regenerate.
>   * src/c++17/cow-string-inst.cc: New file defining explicit
>   instantiations for basic_string member functions added in C++17.
>   * src/c++17/string-inst.cc: Likewise.
>
> Tested powerpc64le-linux, committed to trunk.

this patch broke Solaris bootstrap:

ld: fatal: libstdc++-symbols.ver-sun: 6705: symbol 'std::basic_string, std::allocator >::operator 
std::basic_string_view >() const': symbol version 
conflict
ld: fatal: libstdc++-symbols.ver-sun: 6707: symbol 'std::basic_string, std::allocator >::operator 
std::basic_string_view >() const': symbol 
version conflict
ld: fatal: libstdc++-symbols.ver-sun: 6712: symbol 'std::basic_string, std::allocator >::data()': symbol version conflict
ld: fatal: libstdc++-symbols.ver-sun: 6714: symbol 'std::basic_string, std::allocator >::data()': symbol version 
conflict
ld: fatal: libstdc++-symbols.ver-sun: 6723: symbol 
'std::__cxx11::basic_string, std::allocator 
>::_S_to_string_view(std::basic_string_view >)': 
symbol version conflict
ld: fatal: libstdc++-symbols.ver-sun: 6724: symbol 
'std::__cxx11::basic_string, 
std::allocator >::_S_to_string_view(std::basic_string_view >)': symbol version conflict
collect2: error: ld returned 1 exit status
make[6]: *** [Makefile:696: libstdc++.la] Error 1

Rerunning with COLLECT_NO_DEMANGLE=1 gives (with symbol versions and
patterns matched extracted from libstdc++-symbols.ver-sun):

d: fatal: libstdc++-symbols.ver-sun: 6705: symbol 
'_ZNKSscvSt17basic_string_viewIcSt11char_traitsIcEEEv': symbol version conflict

  GLIBCXX_3.4
##_ZNKSs[a-z]* (glob)
_ZNKSscvSt17basic_string_viewIcSt11char_traitsIcEEEv;
  GLIBCXX_3.4.26
##_ZNKSscvSt17basic_string_viewIcSt11char_traitsIcEEEv (glob)
_ZNKSscvSt17basic_string_viewIcSt11char_traitsIcEEEv;

ld: fatal: libstdc++-symbols.ver-sun: 6707: symbol 
'_ZNKSbIwSt11char_traitsIwESaIwEEcvSt17basic_string_viewIwS0_EEv': symbol 
version conflict

  GLIBCXX_3.4
##_ZNKSbIwSt11char_traitsIwESaIwEE[a-z]* (glob)
_ZNKSbIwSt11char_traitsIwESaIwEEcvSt17basic_string_viewIwS0_EEv;
  GLIBCXX_3.4.26
##_ZNKSbIwSt11char_traitsIwESaIwEE[a-z]* (glob)
_ZNKSbIwSt11char_traitsIwESaIwEEcvSt17basic_string_viewIwS0_EEv;

ld: fatal: libstdc++-symbols.ver-sun: 6712: symbol '_ZNSs4dataEv': symbol 
version conflict

  GLIBCXX_3.4
##_ZNSs[0-58-9][c-e]* (glob)
_ZNSs4dataEv;
  GLIBCXX_3.4.26
##_ZNSs4dataEv (glob)
_ZNSs4dataEv;

ld: fatal: libstdc++-symbols.ver-sun: 6714: symbol 
'_ZNSbIwSt11char_traitsIwESaIwEE4dataEv': symbol version conflict

  GLIBCXX_3.4
##_ZNSbIwSt11char_traitsIwESaIwEE[0-58-9][c-e]* (glob)
_ZNSbIwSt11char_traitsIwESaIwEE4dataEv;
  GLIBCXX_3.4.26
##_ZNSbIwSt11char_traitsIwESaIwEE4dataEv (glob)
_ZNSbIwSt11char_traitsIwESaIwEE4dataEv;

ld: fatal: libstdc++-symbols.ver-sun: 6723: symbol 
'_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE17_S_to_string_viewESt17basic_string_viewIcS2_E':
 symbol version conflict

  GLIBCXX_3.4.21
##_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE1[5-9]* 
(glob)

_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE17_S_to_string_viewESt17basic_string_viewIcS2_E;
  GLIBCXX_3.4.26

##_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE17_S_to_string_viewESt17basic_string_viewI[cw]S2_E
 (glob)

_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE17_S_to_string_viewESt17basic_string_viewIcS2_E;

ld: fatal: libstdc++-symbols.ver-sun: 6724: symbol 
'_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE17_S_to_string_viewESt17basic_string_viewIwS2_E':
 symbol version conflict

  GLIBCXX_3.4.21
##_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE1[5-9]* 
(glob)

_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE17_S_to_string_viewESt17basic_string_viewIwS2_E;

Re: [PATCH] Export explicit instantiations for C++17 members of std::string

2019-01-06 Thread Jonathan Wakely

On 06/01/19 17:59 +0100, Rainer Orth wrote:

Hi Jonathan,


The C++17 standard added some new members to std::basic_string, which
were not previously instantiated in the library. This meant that the
extern template declarations had to be disabled for C++17 mode. With
this patch the new members are instantiated in the library and so the
explicit instantiation declarations can be used for C++17.

The new members added by C++2a are still not exported, and so the
explicit instantiation declarations are still disabled for C++2a.

* config/abi/pre/gnu.ver (GLIBCXX_3.4.21): Make patterns less greedy
for const member functions of std::basic_string.
(GLIBCXX_3.4.26): Export member functions of std::basic_string added
in C++17.
* include/bits/basic_string.h (basic_string(__sv_wrapper, const A&)):
Make non-standard constructor private.
[!_GLIBCXX_USE_CXX11_ABI] (basic_string(__sv_wrapper, const A&)):
Likewise.
* include/bits/basic_string.tcc (std::string, std::wstring): Declare
explicit instantiations for C++17 as well as earlier dialects.
* src/c++17/Makefile.am: Add new source files.
* src/c++17/Makefile.in: Regenerate.
* src/c++17/cow-string-inst.cc: New file defining explicit
instantiations for basic_string member functions added in C++17.
* src/c++17/string-inst.cc: Likewise.

Tested powerpc64le-linux, committed to trunk.


this patch broke Solaris bootstrap:

ld: fatal: libstdc++-symbols.ver-sun: 6705: symbol 'std::basic_string, 
std::allocator >::operator std::basic_string_view >() 
const': symbol version conflict
ld: fatal: libstdc++-symbols.ver-sun: 6707: symbol 'std::basic_string, std::allocator >::operator 
std::basic_string_view >() const': symbol version conflict
ld: fatal: libstdc++-symbols.ver-sun: 6712: symbol 'std::basic_string, std::allocator >::data()': symbol version conflict
ld: fatal: libstdc++-symbols.ver-sun: 6714: symbol 'std::basic_string, std::allocator >::data()': symbol version 
conflict
ld: fatal: libstdc++-symbols.ver-sun: 6723: symbol 'std::__cxx11::basic_string, std::allocator 
>::_S_to_string_view(std::basic_string_view >)': symbol version 
conflict
ld: fatal: libstdc++-symbols.ver-sun: 6724: symbol 'std::__cxx11::basic_string, std::allocator 
>::_S_to_string_view(std::basic_string_view >)': symbol 
version conflict
collect2: error: ld returned 1 exit status
make[6]: *** [Makefile:696: libstdc++.la] Error 1


Sorry :-(

[...]


The following patch allowed the build to finish.


OK for trunk, thanks.

I'll make sure to run my script to check for such conflicts before
adding any more symbols.



Revert inliner badness change from 2017

2019-01-06 Thread Jan Hubicka
Hi,
the PR tree-opt/86020 track regression from patch I committed in
2017-05-22.  I believe I did so accidentally becuase the patch does not
make much sense to me - the badness is documented as:

  /* When profile is available. Compute badness as:
 
 time_saved * caller_count
 goodness =  -
 growth_of_caller * overall_growth * combined_size

 badness = - goodness

 Again use negative value to make calls with profile appear hotter
 then calls without.
  */

And the code computes combined_size while I have chnaged it to be
inlined_time.  I see no reason for penalizing functions running for long
time and I believed I meant it as a micro optimization since I read the
calcuation as time instead of size calculatoin.

I did some benchmarking on SPEC and Firefox and while there are changes
it seems neutral overall and thus I have decided to revert the patch.

Bootstrapped/regtested x86_64-linux, comitted.

PR tree-opt/86020
Revert:
2017-05-22  Jan Hubicka  

* ipa-inline.c (edge_badness): Use inlined_time instead of
inline_summaries->get.

Index: ipa-inline.c
===
--- ipa-inline.c(revision 267610)
+++ ipa-inline.c(working copy)
@@ -1173,7 +1173,7 @@
overall_growth += 256 * 256 - 256;
  denominator *= overall_growth;
 }
-  denominator *= inlined_time;
+  denominator *= ipa_fn_summaries->get (caller)->self_size + growth;
 
   badness = - numerator / denominator;
 


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

2019-01-06 Thread Martin Liška

On 11/19/18 11:38 AM, Lokesh Janghel wrote:

Thank you Jakub, I update the patch with your comments and tested it.
Please let me know your thoughts/suggestions.

On Mon, Nov 19, 2018 at 4:00 PM Lokesh Janghel
 wrote:


Thank you Jakub, I update the patch with your comments and tested it.
Please let me know your thoughts/suggestions.


Thanks
Lokesh

On Fri, Nov 16, 2018 at 4:57 PM Jakub Jelinek  wrote:


On Fri, Nov 16, 2018 at 04:21:25PM +0530, Umesh Kalappa wrote:

My bad ,
attached the same now .


+2018-11-15  Lokesh Janghel 

Two spaces before < instead of just one.
+
+   PR  target/85667

Only a single space between PR and target.

+   * i386.c (function_value_ms_64): ms_abi insist to use the eax

The filename is relative to the directory with ChangeLog file, so
 * config/i386/i386.c
in this case.  The description should say what you've changed, so
something like:
 * config/i386/i386.c (function_value_ms_64): Return AX_REG instead
 of FIRST_SSE_REG for 4 or 8 byte modes.

--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -9008,7 +9008,7 @@ function_value_ms_64 (machine_mode orig_mode, 
machine_mode mode,
 case 8:
 case 4:
   if (mode == SFmode || mode == DFmode)
-   regno = FIRST_SSE_REG;
+   regno = AX_REG;
   break;

Is there something to back that up, say godbolt.org link with some testcases
showing how does MSVC, clang etc. handle those?
And, because the function starts with:
   unsigned int regno = AX_REG;
the change isn't right, you should remove all of:
 case 8:
 case 4:
   if (mode == SFmode || mode == DFmode)
 regno = FIRST_SSE_REG;
   break;
because the default will do what you want.

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 50e53f0..ec54330 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-11-15 Lokesh Janghel  

Two spaces between date and name.

--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr85667.c
@@ -0,0 +1,29 @@
+/* { dg-options "-O2 " } */
+/* { dg-final { scan-assembler-times "movl\[\t 
\]\.\[a-zA-Z\]\[a-zA-Z\]\[0-9\]\\(%rip\\), %eax" 1} } */

First of all, the test is misplaced, it is clearly x86_64 specific
and probably lp64 only, so it shouldn't be in gcc.dg/ where it will
be run on all targets, but in gcc.target/i386/ and be guarded with
{ target lp64 }.

Second, seems like you'd like to run the testcase, so you'd better have it
/* { dg-do run { target lp64 } } */

The assembler scanning will work only with -masm=att, not -masm=intel
and seems to be very fragile, so I'd suggest have one runtime test and one
compile time test in which you put just the fn1 function.  Why two arbitrary
letters after dot?  That makes on sense.  Either you are looking for .LC\[0-9]*
specifically, or for arbitrary symbol, then use something like
"movl\[^\n\r]*, %eax"
or so (and make sure to use -masm=intel).

More interesting would be
make check ALT_CC_UNDER_TEST=msvc ALT_CXX_UNDER_TEST=msvc++ 
RUNTESTFLAGS='compat.exp struct-layout-1.exp'
(or whatever MSVC driver names are), i.e. try to run the compat testsuites
between MSVC and newly built gcc.

 Jakub




--
Thanks & Regards
Lokesh Janghel
+91-9752984749






Hi.

The patch causes failures in libffi:
https://github.com/libffi/libffi/issues/463

Can you please take a look?
Martin



Re: [PATCH] Export explicit instantiations for C++17 members of std::string

2019-01-06 Thread Jonathan Wakely

On 06/01/19 17:18 +, Jonathan Wakely wrote:

On 06/01/19 17:59 +0100, Rainer Orth wrote:

Hi Jonathan,


The C++17 standard added some new members to std::basic_string, which
were not previously instantiated in the library. This meant that the
extern template declarations had to be disabled for C++17 mode. With
this patch the new members are instantiated in the library and so the
explicit instantiation declarations can be used for C++17.

The new members added by C++2a are still not exported, and so the
explicit instantiation declarations are still disabled for C++2a.

* config/abi/pre/gnu.ver (GLIBCXX_3.4.21): Make patterns less greedy
for const member functions of std::basic_string.
(GLIBCXX_3.4.26): Export member functions of std::basic_string added
in C++17.
* include/bits/basic_string.h (basic_string(__sv_wrapper, const A&)):
Make non-standard constructor private.
[!_GLIBCXX_USE_CXX11_ABI] (basic_string(__sv_wrapper, const A&)):
Likewise.
* include/bits/basic_string.tcc (std::string, std::wstring): Declare
explicit instantiations for C++17 as well as earlier dialects.
* src/c++17/Makefile.am: Add new source files.
* src/c++17/Makefile.in: Regenerate.
* src/c++17/cow-string-inst.cc: New file defining explicit
instantiations for basic_string member functions added in C++17.
* src/c++17/string-inst.cc: Likewise.

Tested powerpc64le-linux, committed to trunk.


this patch broke Solaris bootstrap:

ld: fatal: libstdc++-symbols.ver-sun: 6705: symbol 'std::basic_string, 
std::allocator >::operator std::basic_string_view >() 
const': symbol version conflict
ld: fatal: libstdc++-symbols.ver-sun: 6707: symbol 'std::basic_string, std::allocator >::operator 
std::basic_string_view >() const': symbol version conflict
ld: fatal: libstdc++-symbols.ver-sun: 6712: symbol 'std::basic_string, std::allocator >::data()': symbol version conflict
ld: fatal: libstdc++-symbols.ver-sun: 6714: symbol 'std::basic_string, std::allocator >::data()': symbol version 
conflict
ld: fatal: libstdc++-symbols.ver-sun: 6723: symbol 'std::__cxx11::basic_string, std::allocator 
>::_S_to_string_view(std::basic_string_view >)': symbol version 
conflict
ld: fatal: libstdc++-symbols.ver-sun: 6724: symbol 'std::__cxx11::basic_string, std::allocator 
>::_S_to_string_view(std::basic_string_view >)': symbol 
version conflict
collect2: error: ld returned 1 exit status
make[6]: *** [Makefile:696: libstdc++.la] Error 1


Sorry :-(

[...]


The following patch allowed the build to finish.


OK for trunk, thanks.

I'll make sure to run my script to check for such conflicts before
adding any more symbols.



The good news is that even with my soon-to-be-committed changes, I
only see the same problems you already found:

Symbol matches more than one version:
_ZNKSbIwSt11char_traitsIwESaIwEEcvSt17basic_string_viewIwS0_EEv
std::basic_string, std::allocator >::operator 
std::basic_string_view >() const
 GLIBCXX_3.4_ZNKSbIwSt11char_traitsIwESaIwEE[a-z]* (line 327)
 GLIBCXX_3.4.26 
_ZNKSbIwSt11char_traitsIwESaIwEEcvSt17basic_string_viewIwS0_EEv (line 2098)

Symbol matches more than one version:
_ZNKSscvSt17basic_string_viewIcSt11char_traitsIcEEEv
std::basic_string, std::allocator >::operator 
std::basic_string_view >() const
 GLIBCXX_3.4_ZNKSs[a-z]* (line 261)
 GLIBCXX_3.4.26 _ZNKSscvSt17basic_string_viewIcSt11char_traitsIcEEEv (line 
2097)

Symbol matches more than one version:
_ZNSbIwSt11char_traitsIwESaIwEE4dataEv
std::basic_string, std::allocator 
>::data()
 GLIBCXX_3.4_ZNSbIwSt11char_traitsIwESaIwEE[0-58-9][c-e]* (line 287)
 GLIBCXX_3.4.26 _ZNSbIwSt11char_traitsIwESaIwEE4dataEv (line 2102)

Symbol matches more than one version:
_ZNSs4dataEv
std::basic_string, std::allocator >::data()
 GLIBCXX_3.4_ZNSs[0-58-9][c-e]* (line 220)
 GLIBCXX_3.4.26 _ZNSs4dataEv (line 2101)

Symbol matches more than one version:
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE17_S_to_string_viewESt17basic_string_viewIcS2_E
std::__cxx11::basic_string, std::allocator 
>::_S_to_string_view(std::basic_string_view >)
 GLIBCXX_3.4.21 
_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE1[5-9]* (line 
1720)
 GLIBCXX_3.4.26 
_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE17_S_to_string_viewESt17basic_string_viewI[cw]S2_E
 (line 2107)

Symbol matches more than one version:
_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE17_S_to_string_viewESt17basic_string_viewIwS2_E
std::__cxx11::basic_string, std::allocator 
>::_S_to_string_view(std::basic_string_view >)
 GLIBCXX_3.4.21 
_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE1[5-9]* (line 
1720)
 GLIBCXX_3.4.26 
_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE17_S_to_string_viewESt17basic_string_viewI[cw]S2_E
 (line 2107)




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

2019-01-06 Thread Jakub Jelinek
On Sun, Jan 06, 2019 at 06:25:35PM +0100, Martin Liška wrote:
> The patch causes failures in libffi:
> https://github.com/libffi/libffi/issues/463
> 
> Can you please take a look?

Perhaps PR88521?  A patch has been posted for that and even approved:
https://gcc.gnu.org/ml/gcc-patches/2018-12/msg01682.html
but not actually committed yet.

Jakub


[PATCH] PR libstdc++/87431 fix regression introduced by r264574

2019-01-06 Thread Jonathan Wakely

The previous patch for PR 87431 assumed that initialing a scalar type
could not throw, but it can obtain its value via a conversion operator,
which could throw. This meant the variant could get into a valueless
state, but the valueless_by_exception() member function would always
return false.

This patch fixes it by changing the emplace members to have strong
exception safety when initializing a contained value of trivially
copyable type. The _M_valid() member gets a corresponding change to
always return true for trivially copyable types, not just scalar types.

Strong exception safety (i.e. never becoming valueless) is achieved by
only replacing the current contained value once any potentially throwing
operations have completed. If constructing the new contained value can
throw then a new std::variant object is constructed to hold it, and then
move-assigned to *this (which won't throw).

PR libstdc++/87431
* include/std/variant (_Variant_storage::_M_valid):
Check is_trivially_copyable instead of is_scalar.
(variant::emplace(Args&&...)): If construction of the new
contained value can throw and its type is trivially copyable then
construct into a temporary variant and move from it, to provide the
strong exception safety guarantee.
(variant::emplace(initializer_list, Args&&...)):
Likewise.
* testsuite/20_util/variant/87431.cc: New test.
* testsuite/20_util/variant/run.cc: Adjust test so that throwing
conversion causes valueless state.

Tested powerpc64-linux, committed to trunk.

commit 54cf49b46d1517752290f9e2c39604f7d40784c6
Author: Jonathan Wakely 
Date:   Fri Jan 4 18:07:50 2019 +

PR libstdc++/87431 fix regression introduced by r264574

The previous patch for PR 87431 assumed that initialing a scalar type
could not throw, but it can obtain its value via a conversion operator,
which could throw. This meant the variant could get into a valueless
state, but the valueless_by_exception() member function would always
return false.

This patch fixes it by changing the emplace members to have strong
exception safety when initializing a contained value of trivially
copyable type. The _M_valid() member gets a corresponding change to
always return true for trivially copyable types, not just scalar types.

Strong exception safety (i.e. never becoming valueless) is achieved by
only replacing the current contained value once any potentially throwing
operations have completed. If constructing the new contained value can
throw then a new std::variant object is constructed to hold it, and then
move-assigned to *this (which won't throw).

PR libstdc++/87431
* include/std/variant (_Variant_storage::_M_valid):
Check is_trivially_copyable instead of is_scalar.
(variant::emplace(Args&&...)): If construction of the new
contained value can throw and its type is trivially copyable then
construct into a temporary variant and move from it, to provide the
strong exception safety guarantee.
(variant::emplace(initializer_list, Args&&...)):
Likewise.
* testsuite/20_util/variant/87431.cc: New test.
* testsuite/20_util/variant/run.cc: Adjust test so that throwing
conversion causes valueless state.

diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index 6f2205c3507..83cf99e9ae0 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -439,7 +439,7 @@ namespace __variant
   constexpr bool
   _M_valid() const noexcept
   {
-   if constexpr ((is_scalar_v<_Types> && ...))
+   if constexpr ((is_trivially_copyable_v<_Types> && ...))
  return true;
return this->_M_index != __index_type(variant_npos);
   }
@@ -1185,6 +1185,23 @@ namespace __variant
{
  static_assert(_Np < sizeof...(_Types),
"The index should be in [0, number of alternatives)");
+
+ using type = variant_alternative_t<_Np, variant>;
+ // If constructing the value can throw but move assigning it can't,
+ // construct in a temporary and then move assign from it. This gives
+ // the strong exception safety guarantee, ensuring we never become
+ // valueless.
+ if constexpr (is_trivially_copyable_v
+ && !is_nothrow_constructible_v)
+   {
+ // If move assignment cannot throw then we can provide the
+ // strong exception safety guarantee, and never become valueless.
+ variant __tmp(in_place_index<_Np>,
+   std::forward<_Args>(__args)...);
+ *this = std::move(__tmp);
+ return std::get<_Np>(*this);
+   }
+
  this->~variant();
  __try
{
@@ -1208,6 +1

Re: [PATCH] Define new filesystem::__file_clock type

2019-01-06 Thread Jonathan Wakely

On 05/01/19 20:03 +, Jonathan Wakely wrote:

In C++17 the clock used for filesystem::file_time_type is unspecified,
allowing it to be chrono::system_clock. The C++2a draft requires it to
be a distinct type, with additional member functions to convert to/from
other clocks (either the system clock or UTC). In order to avoid an ABI
change later, this patch defines a new distinct type now, which will be
used for std::chrono::file_clock later.

* include/bits/fs_fwd.h (__file_clock): Define new clock.
(file_time_type): Redefine in terms of __file_clock.
* src/filesystem/ops-common.h (file_time): Add FIXME comment about
overflow.
* src/filesystem/std-ops.cc (is_set(perm_options, perm_options)): Give
internal linkage.
(internal_file_lock): New helper type for accessing __file_clock.
(do_copy_file): Use internal_file_lock to convert system time to
file_time_type.
(last_write_time(const path&, error_code&)): Likewise.
(last_write_time(const path&, file_time_type, error_code&)): Likewise.

Tested powerpc64-linux, committed to trunk.


There's a new failure on 32-bit x86:

/home/jwakely/src/gcc/gcc/libstdc++-v3/testsuite/27_io/filesystem/operations/last_write_time.cc:148:
 void test02(): Assertion 'approx_equal(last_write_time(f.path), time)' failed.
FAIL: 27_io/filesystem/operations/last_write_time.cc execution test

I'll deal with that ASAP.




[patch, fortran] Implement IS_CONTINUOUS intrinsic

2019-01-06 Thread Thomas Koenig

Hello world,

the attached patch builds on a long history:  Tobias Burnus created
an original version in 2012. Harald Anlauf recently picked it up,
(see https://gcc.gnu.org/ml/fortran/2019-01/msg00012.html).
polished it and made it ready for gcc-9.  This already worked
quite well.  I added a bit of compile-time simplification (where we can
prove an array is not contiguous). The original library function version
was by Harald, but I replaced that with something simpler; also the
code would have pushed the limits for contributions without
(yet) a copyright assignment in place.

Later, we can also use the gfc_is_not_contiguous to reject
obvious errors when assigning to contiguous pointers or
arguments.

Regression-tested on x86_64-pc-linux-gnu. OK for trunk?

Regards

Thomas

2019-01-06  Thomas Koenig  
Harald Anlauf 
Tobias Burnus 

PR fortran/45424
* check.c (gfc_check_is_contiguous): New function.
* expr.c (gfc_is_not_contiguous): New function.
* gfortran.h (gfc_isym_id): Add GFC_ISYM_IS_CONTIGUOUS.
Add prototype for gfc_is_not_contiguous.
* intrinsic.c (do_ts29113_check): Add GFC_ISYM_IS_CONTIGUOUS.
(add_function): Add is_contiguous.
* intrinsic.h: Add prototypes for gfc_check_is_contiguous,
gfc_simplify_is_contiguous and gfc_resolve_is_contiguous.
* intrinsic.texi: Add IS_CONTIGUOUS.
* iresolve.c (gfc_resolve_is_contiguous): New function.
* simplify.c (gfc_simplify_is_contiguous): New function.
* trans-decl.c (gfor_fncecl_is_contiguous0): New variable.
(gfc_build_intrinsic_function_decl): Add it.
* trans-intrinsic.c (gfc_conv_intrinsic_is_contiguous): New
function.
(gfc_conv_intrinsic_function): Handle GFC_ISYM_IS_CONTIGUOUS.

2019-01-06  Thomas Koenig  
Harald Anlauf 
Tobias Burnus 

PR fortran/45424
* Makefile.am: Add intrinsics/is_contiguous.c.
* Makefile.in: Regenerated.
* gfortran.map: Add _gfortran_is_contiguous0.
* intrinsics/is_contiguous.c: New file.
* libgfortran.h: Add prototype for is_contiguous0.
Index: gcc/fortran/check.c
===
--- gcc/fortran/check.c	(Revision 267553)
+++ gcc/fortran/check.c	(Arbeitskopie)
@@ -6500,6 +6500,17 @@ gfc_check_ttynam_sub (gfc_expr *unit, gfc_expr *na
 
 
 bool
+gfc_check_is_contiguous (gfc_expr *array)
+{
+  if (!array_check (array, 0))
+return false;
+
+  return true;
+}
+
+
+
+bool
 gfc_check_isatty (gfc_expr *unit)
 {
   if (unit == NULL)
Index: gcc/fortran/expr.c
===
--- gcc/fortran/expr.c	(Revision 267553)
+++ gcc/fortran/expr.c	(Arbeitskopie)
@@ -5695,7 +5695,76 @@ gfc_is_simply_contiguous (gfc_expr *expr, bool str
   return true;
 }
 
+/* Return true if the expression is guaranteed to be non-contiguous,
+   false if we cannot prove anything.  It is probably best to call
+   this after gfc_is_simply_contiguous.  If neither of them returns
+   true, we cannot say (at compile-time).  */
 
+bool
+gfc_is_not_contiguous (gfc_expr *array)
+{
+  int i;
+  gfc_array_ref *ar = NULL;
+  gfc_ref *ref;
+  bool previous_incomplete;
+
+  for (ref = array->ref; ref; ref = ref->next)
+{
+  /* Array-ref shall be last ref.  */
+
+  if (ar)
+	return true;
+
+  if (ref->type == REF_ARRAY)
+	ar = &ref->u.ar;
+}
+
+  if (ar == NULL || ar->type != AR_SECTION)
+return false;
+
+  previous_incomplete = false;
+
+  /* Check if we can prove that the array is not contiguous.  */
+
+  for (i = 0; i < ar->dimen; i++)
+{
+  mpz_t arr_size, ref_size;
+
+  if (gfc_ref_dimen_size (ar, i, &ref_size, NULL))
+	{
+	  if (gfc_dep_difference (ar->as->lower[i], ar->as->upper[i], &arr_size))
+	{
+	  /* a(2:4,2:) is known to be non-contiguous, but
+		 a(2:4,i:i) can be contiguous.  */
+	  if (previous_incomplete && mpz_cmp_si (ref_size, 1) != 0)
+		{
+		  mpz_clear (arr_size);
+		  mpz_clear (ref_size);
+		  return true;
+		}
+	  else if (mpz_cmp (arr_size, ref_size) != 0)
+		previous_incomplete = true;
+
+	  mpz_clear (arr_size);
+	}
+
+	  /* Check for a(::2), i.e. where the stride is not unity.
+	 This is only done if there is more than one element in
+	 the reference along this dimension.  */
+
+	  if (mpz_cmp_ui (ref_size, 1) > 0 && ar->type == AR_SECTION
+	  && ar->dimen_type[i] == DIMEN_RANGE
+	  && ar->stride[i] && ar->stride[i]->expr_type == EXPR_CONSTANT
+	  && mpz_cmp_si (ar->stride[i]->value.integer, 1) != 0)
+	return true;
+
+	  mpz_clear (ref_size);
+	}
+}
+  /* We didn't find anything definitive.  */
+  return false;
+}
+
 /* Build call to an intrinsic procedure.  The number of arguments has to be
passed (rather than ending the list with a NULL value) because we may
want to add arguments but with a NULL-expression.  */
Index: gcc/fortran/gfo

[PATCH 1/2] PR libstdc++/86756 add std::filesystem::path to libstdc++.so

2019-01-06 Thread Jonathan Wakely

Move the C++17 std::filesystem::path definitions from the libstdc++fs.a
archive to the main libstdc++ library. The path classes do not depend on
any OS functions, so can be defined unconditionally on all targets
(rather than depending on --enable-libstdcxx-filesystem-ts). The tests
should pass on all targets too.

PR libstdc++/86756
* config/abi/pre/gnu.ver (GLIBCXX_3.4): Make various patterns for
typeinfo and vtables less greedy.
(GLIBCXX_3.4.26): Export symbols for std::filesystem::path.
* src/c++17/Makefile.am: Add fs_path.cc and cow-fs_path.cc.
* src/c++17/Makefile.in: Regenerate.
* src/c++17/cow-fs_path.cc: Move src/filesystem/cow-std-path.cc to
here, and change name of included file.
* src/c++17/fs_path.cc: Move src/filesystem/std-path.cc to here.
* src/filesystem/Makefile.am: Remove std-path.cc and cow-std-path.cc
from sources.
* src/filesystem/Makefile.in: Regenerate.
* src/filesystem/cow-std-path.cc: Move to src/c++17/cow-fs_path.cc.
* src/filesystem/std-path.cc: Move to src/c++17/fs_path.cc.
* testsuite/27_io/filesystem/path/append/path.cc: Remove -lstdc++fs
from dg-options and remove dg-require-filesystem-ts.
* testsuite/27_io/filesystem/path/append/source.cc: Likewise.
* testsuite/27_io/filesystem/path/assign/assign.cc: Likewise.
* testsuite/27_io/filesystem/path/assign/copy.cc: Likewise.
* testsuite/27_io/filesystem/path/compare/compare.cc: Likewise.
* testsuite/27_io/filesystem/path/compare/lwg2936.cc: Likewise.
* testsuite/27_io/filesystem/path/compare/path.cc: Likewise.
* testsuite/27_io/filesystem/path/compare/strings.cc: Likewise.
* testsuite/27_io/filesystem/path/concat/path.cc: Likewise.
* testsuite/27_io/filesystem/path/concat/strings.cc: Likewise.
* testsuite/27_io/filesystem/path/construct/80762.cc: Likewise.
* testsuite/27_io/filesystem/path/construct/copy.cc: Likewise.
* testsuite/27_io/filesystem/path/construct/default.cc: Likewise.
* testsuite/27_io/filesystem/path/construct/format.cc: Likewise.
* testsuite/27_io/filesystem/path/construct/locale.cc: Likewise.
* testsuite/27_io/filesystem/path/construct/range.cc: Likewise.
* testsuite/27_io/filesystem/path/construct/string_view.cc: Likewise.
* testsuite/27_io/filesystem/path/decompose/extension.cc: Likewise.
* testsuite/27_io/filesystem/path/decompose/filename.cc: Likewise.
* testsuite/27_io/filesystem/path/decompose/parent_path.cc: Likewise.
* testsuite/27_io/filesystem/path/decompose/relative_path.cc: Likewise.
* testsuite/27_io/filesystem/path/decompose/root_directory.cc:
Likewise.
* testsuite/27_io/filesystem/path/decompose/root_name.cc: Likewise.
* testsuite/27_io/filesystem/path/decompose/root_path.cc: Likewise.
* testsuite/27_io/filesystem/path/decompose/stem.cc: Likewise.
* testsuite/27_io/filesystem/path/generation/normal.cc: Likewise.
* testsuite/27_io/filesystem/path/generation/normal2.cc: Likewise.
* testsuite/27_io/filesystem/path/generation/proximate.cc: Likewise.
* testsuite/27_io/filesystem/path/generation/relative.cc: Likewise.
* testsuite/27_io/filesystem/path/generic/generic_string.cc: Likewise.
* testsuite/27_io/filesystem/path/itr/components.cc: Likewise.
* testsuite/27_io/filesystem/path/itr/traversal.cc: Likewise.
* testsuite/27_io/filesystem/path/modifiers/clear.cc: Likewise.
* testsuite/27_io/filesystem/path/modifiers/make_preferred.cc:
Likewise.
* testsuite/27_io/filesystem/path/modifiers/remove_filename.cc:
Likewise.
* testsuite/27_io/filesystem/path/modifiers/replace_extension.cc:
Likewise.
* testsuite/27_io/filesystem/path/modifiers/replace_filename.cc:
Likewise.
* testsuite/27_io/filesystem/path/modifiers/swap.cc: Likewise.
* testsuite/27_io/filesystem/path/native/string.cc: Likewise.
* testsuite/27_io/filesystem/path/nonmember/append.cc: Likewise.
* testsuite/27_io/filesystem/path/nonmember/hash_value.cc: Likewise.
* testsuite/27_io/filesystem/path/query/empty.cc: Likewise.
* testsuite/27_io/filesystem/path/query/has_extension.cc: Likewise.
* testsuite/27_io/filesystem/path/query/has_filename.cc: Likewise.
* testsuite/27_io/filesystem/path/query/has_parent_path.cc: Likewise.
* testsuite/27_io/filesystem/path/query/has_relative_path.cc: Likewise.
* testsuite/27_io/filesystem/path/query/has_root_directory.cc:
Likewise.
* testsuite/27_io/filesystem/path/query/has_root_name.cc: Likewise.
* testsuite/27_io/filesystem/path/query/has_root_path.cc: Likewise.
* testsuite/27_io/filesystem/path/query/has_stem.cc: Likewise.
* testsuite/27_io/file

Re: [PATCH] genattrtab bit-rot, and if_then_else in values

2019-01-06 Thread Alan Modra
On Fri, Jan 04, 2019 at 12:18:03PM +, Richard Sandiford wrote:
> Alan Modra  writes:
> > On Thu, Jan 03, 2019 at 07:03:59PM +, Richard Sandiford wrote:
> >> Richard Sandiford  writes:
> >> > This still seems risky and isn't what the name and function comment
> >
> > OK, how about this delta from the previous patch to ameliorate the
> > maintenance risk?
> 
> attr_value_alignment seems clearer, and means that we can handle
> things like:
> 
>   (mult (symbol_ref "...") (const_int 4))

OK, revised patch as follows, handling MINUS and MULT in the max/min
value functions too.

* genattrtab.c (max_attr_value, min_attr_value, or_attr_value):
Delete "unknownp" parameter.  Adjust callers.  Handle
CONST_INT, PLUS, MINUS, and MULT.
(attr_value_aligned): Renamed from or_attr_value.
(min_attr_value): Return INT_MIN for unhandled rtl case..
(min_fn): ..and translate to INT_MAX here.
(write_length_unit_log): Modify to cope without "unknown".
(write_attr_value): Handle IF_THEN_ELSE.

diff --git a/gcc/genattrtab.c b/gcc/genattrtab.c
index 2cd04cdb06f..b8adf704009 100644
--- a/gcc/genattrtab.c
+++ b/gcc/genattrtab.c
@@ -266,9 +266,9 @@ static int compares_alternatives_p (rtx);
 static void make_internal_attr (const char *, rtx, int);
 static void insert_insn_ent(struct attr_value *, struct insn_ent *);
 static void walk_attr_value   (rtx);
-static int max_attr_value (rtx, int*);
-static int min_attr_value (rtx, int*);
-static int or_attr_value  (rtx, int*);
+static int max_attr_value (rtx);
+static int min_attr_value (rtx);
+static unsigned int attr_value_alignment (rtx);
 static rtx simplify_test_exp  (rtx, int, int);
 static rtx simplify_test_exp_in_temp (rtx, int, int);
 static rtx copy_rtx_unchanging(rtx);
@@ -1550,15 +1550,16 @@ one_fn (rtx exp ATTRIBUTE_UNUSED)
 static rtx
 max_fn (rtx exp)
 {
-  int unknown;
-  return make_numeric_value (max_attr_value (exp, &unknown));
+  return make_numeric_value (max_attr_value (exp));
 }
 
 static rtx
 min_fn (rtx exp)
 {
-  int unknown;
-  return make_numeric_value (min_attr_value (exp, &unknown));
+  int val = min_attr_value (exp);
+  if (val < 0)
+val = INT_MAX;
+  return make_numeric_value (val);
 }
 
 static void
@@ -1568,24 +1569,21 @@ write_length_unit_log (FILE *outf)
   struct attr_value *av;
   struct insn_ent *ie;
   unsigned int length_unit_log, length_or;
-  int unknown = 0;
 
   if (length_attr)
 {
-  length_or = or_attr_value (length_attr->default_val->value, &unknown);
+  length_or = attr_value_alignment (length_attr->default_val->value);
   for (av = length_attr->first_value; av; av = av->next)
for (ie = av->first_insn; ie; ie = ie->next)
- length_or |= or_attr_value (av->value, &unknown);
-}
+ length_or |= attr_value_alignment (av->value);
 
-  if (length_attr == NULL || unknown)
-length_unit_log = 0;
-  else
-{
   length_or = ~length_or;
   for (length_unit_log = 0; length_or & 1; length_or >>= 1)
length_unit_log++;
 }
+  else
+length_unit_log = 0;
+
   fprintf (outf, "EXPORTED_CONST int length_unit_log = %u;\n", 
length_unit_log);
 }
 
@@ -3753,11 +3751,12 @@ write_test_expr (FILE *outf, rtx exp, unsigned int 
attrs_cached, int flags,
   return attrs_cached;
 }
 
-/* Given an attribute value, return the maximum CONST_STRING argument
-   encountered.  Set *UNKNOWNP and return INT_MAX if the value is unknown.  */
+/* Given an attribute value expression, return the maximum value that
+   might be evaluated assuming all conditionals are independent.
+   Return INT_MAX if the value can't be calculated by this function.  */
 
 static int
-max_attr_value (rtx exp, int *unknownp)
+max_attr_value (rtx exp)
 {
   int current_max;
   int i, n;
@@ -3768,25 +3767,62 @@ max_attr_value (rtx exp, int *unknownp)
   current_max = atoi (XSTR (exp, 0));
   break;
 
+case CONST_INT:
+  current_max = INTVAL (exp);
+  break;
+
+case PLUS:
+  current_max = max_attr_value (XEXP (exp, 0));
+  if (current_max != INT_MAX)
+   {
+ n = current_max;
+ current_max = max_attr_value (XEXP (exp, 1));
+ if (current_max != INT_MAX)
+   current_max += n;
+   }
+  break;
+
+case MINUS:
+  current_max = max_attr_value (XEXP (exp, 0));
+  if (current_max != INT_MAX)
+   {
+ n = min_attr_value (XEXP (exp, 1));
+ if (n == INT_MIN)
+   current_max = INT_MAX;
+ else
+   current_max -= n;
+   }
+  break;
+
+case MULT:
+  current_max = max_attr_value (XEXP (exp, 0));
+  if (current_max != INT_MAX)
+   {
+ n = current_max;
+ current_max = max_attr_value (XEXP (exp, 1));
+ if (current_max != INT_MAX)
+   current_max *= n;
+   }
+  break;
+
 case COND:
-  current_max = max_attr_value (XEXP (exp, 

[PATCH 2/2] PR libstdc++/86756 Move rest of std::filesystem to libstdc++.so

2019-01-06 Thread Jonathan Wakely

Move std::filesystem directory iterators and operations from
libstdc++fs.a to main libstdc++ library. These components have many
dependencies on OS support, which is not available on all targets. Some
additional autoconf checks and conditional compilation is needed to
ensure the files will build for all targets. Previously this code was
not compiled without --enable-libstdcxx-filesystem-ts but the C++17
components should be available for all hosted builds.

The tests for these components no longer need to link to libstdc++fs.a,
but are not expected to pass on all targets. To avoid numerous failures
on targets which are not expected to pass the tests (due to missing OS
functionality) leave the dg-require-filesystem-ts directives in place
for now. This will ensure the tests only run for builds where the
filesystem-ts library is built, which presumably means some level of OS
support is present.


Tested x86_64-linux (old/new string ABIs, 32/64 bit), x86_64-w64-mingw32.

Committed to trunk.

commit e83709b79c339f92fbcee748bbe755bf40825210
Author: Jonathan Wakely 
Date:   Sun Jan 6 17:45:40 2019 +

PR libstdc++/86756 Move rest of std::filesystem to libstdc++.so

Move std::filesystem directory iterators and operations from
libstdc++fs.a to main libstdc++ library. These components have many
dependencies on OS support, which is not available on all targets. Some
additional autoconf checks and conditional compilation is needed to
ensure the files will build for all targets. Previously this code was
not compiled without --enable-libstdcxx-filesystem-ts but the C++17
components should be available for all hosted builds.

The tests for these components no longer need to link to libstdc++fs.a,
but are not expected to pass on all targets. To avoid numerous failures
on targets which are not expected to pass the tests (due to missing OS
functionality) leave the dg-require-filesystem-ts directives in place
for now. This will ensure the tests only run for builds where the
filesystem-ts library is built, which presumably means some level of OS
support is present.

PR libstdc++/86756
* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for utime and
lstat and define _GLIBCXX_USE_UTIME and _GLIBCXX_USE_LSTAT.
* config.h.in: Regenerate.
* config/abi/pre/gnu.ver (GLIBCXX_3.4.26): Export symbols for
remaining std::filesystem types and functions.
* configure: Regenerate.
* src/c++17/Makefile.am: Add C++17 filesystem sources.
* src/c++17/Makefile.in: Regenerate.
* src/c++17/cow-fs_dir.cc: Move src/filesystem/cow-std-dir.cc to
here, and change name of included file.
* src/c++17/cow-fs_ops.cc: Move src/filesystem/cow-std-ops.cc to
here, and change name of included file.
* src/c++17/fs_dir.cc: Move src/filesystem/std-dir.cc to here. Change
path to dir-common.h.
* src/c++17/fs_ops.cc: Move src/filesystem/std-ops.cc to here. Change
path to ops-common.h. Disable -Wunused-parameter warnings.
(internal_file_clock): Define unconditionally.
[!_GLIBCXX_HAVE_SYS_STAT_H] (internal_file_clock::from_stat): Do not
define.
(do_copy_file, do_space): Move definitions to ops.common.h.
(copy, file_size, hard_link_count, last_write_time, space): Only
perform operation when _GLIBCXX_HAVE_SYS_STAT_H is defined, otherwise
report an error.
(last_write_time, read_symlink): Remove unused attributes from
parameters.
* src/filesystem/Makefile.am: Remove C++17 filesystem sources.
* src/filesystem/Makefile.in: Regenerate.
* src/filesystem/cow-std-dir.cc: Move to src/c++17/cow-fs_dir.cc.
* src/filesystem/cow-std-ops.cc: Move to src/c++17/cow-fs_ops.cc.
* src/filesystem/std-dir.cc: Move to src/c++17/fs_dir.cc.
* src/filesystem/std-ops.cc: Move to src/c++17/fs_ops.cc.
* src/filesystem/dir-common.h [!_GLIBCXX_HAVE_DIRENT_H]: Define
dummy types and functions instead of using #error.
* src/filesystem/dir.cc [!_GLIBCXX_HAVE_DIRENT_H]: Use #error.
* src/filesystem/ops-common.h [!_GLIBCXX_USE_LSTAT] (lstat): Define
in terms of stat.
[!_GLIBCXX_HAVE_UNISTD_H]: Define dummy types and functions.
(do_copy_file, do_space): Move definitions here from std-ops.cc.
* src/filesystem/ops.cc: Adjust calls to do_copy_file and do_space
to account for new namespace.
* testsuite/27_io/filesystem/directory_entry/86597.cc: Remove
-lstdc++fs from dg-options.
* testsuite/27_io/filesystem/directory_entry/lwg3171.cc: Likewise.
* testsuite/27_io/filesystem/file_status/1.cc: Likewise.

Re: [patch, fortran] Implement IS_CONTINUOUS intrinsic

2019-01-06 Thread Steve Kargl
On Sun, Jan 06, 2019 at 11:04:12PM +0100, Thomas Koenig wrote:
> 
> the attached patch builds on a long history:  Tobias Burnus created
> an original version in 2012. Harald Anlauf recently picked it up,
> (see https://gcc.gnu.org/ml/fortran/2019-01/msg00012.html).
> polished it and made it ready for gcc-9.  This already worked
> quite well.  I added a bit of compile-time simplification (where we can
> prove an array is not contiguous). The original library function version
> was by Harald, but I replaced that with something simpler; also the
> code would have pushed the limits for contributions without
> (yet) a copyright assignment in place.
> 
> Later, we can also use the gfc_is_not_contiguous to reject
> obvious errors when assigning to contiguous pointers or
> arguments.
> 
> Regression-tested on x86_64-pc-linux-gnu. OK for trunk?
> 

OK.

Thanks Thomas, Harald, and Tobias!

-- 
Steve


New Spanish PO file for 'gcc' (version 8.2.0)

2019-01-06 Thread Translation Project Robot
Hello, gentle maintainer.

This is a message from the Translation Project robot.

A revised PO file for textual domain 'gcc' has been submitted
by the Spanish team of translators.  The file is available at:

https://translationproject.org/latest/gcc/es.po

(This file, 'gcc-8.2.0.es.po', has just now been sent to you in
a separate email.)

All other PO files for your package are available in:

https://translationproject.org/latest/gcc/

Please consider including all of these in your next release, whether
official or a pretest.

Whenever you have a new distribution with a new version number ready,
containing a newer POT file, please send the URL of that distribution
tarball to the address below.  The tarball may be just a pretest or a
snapshot, it does not even have to compile.  It is just used by the
translators when they need some extra translation context.

The following HTML page has been updated:

https://translationproject.org/domain/gcc.html

If any question arises, please contact the translation coordinator.

Thank you for all your work,

The Translation Project robot, in the
name of your translation coordinator.




[RS6000] PR88614, output_operand: invalid %z value

2019-01-06 Thread Alan Modra
The direct cause of this PR is the fact that tls_gdld_nomark didn't
handle indirect calls.  Adding the missing support revealed that most
indirect calls were being optimised back to direct calls anyway, due
to tls_gdld_nomark not checking any of the parallel elements except
the first (plus the extra element that distinguishes this call from
normal calls).  Just checking the number of elements is enough to
separate the indirect calls from direct for ABI_ELFv2 and ABI_AIX,
while checking for the LONG_CALL bit in the cookie works for ABI_V4.
Direct calls being substituted for indirect calls is not the only
unwanted substitution.  See the tls_nomark_call comment.  I also saw a
_GLOBAL_OFFSET_TABLE_ symbol_ref being substituted for the GOT reg,
hence the unspec_tls change.

Bootstrap and regression testing on powerpc64le-linux and
powerpc64-linux in progress.  Note that the patch requires
https://gcc.gnu.org/ml/gcc-patches/2019-01/msg00252.html or the
earlier version for the attribute support.

PR 88614
* config/rs6000/predicates.md (unspec_tls): Ensure GOT reg
stays a reg.
(tls_nomark_call): New.
* config/rs6000/rs6000.c (rs6000_call_sysv): Generate sysv4 secure
plt call pattern here..
* config/rs6000/rs6000.md (call_nonlocal_sysv): ..rather than here,
delete split..
(call_value_nonlocal_sysv): ..or here, delete split.
(tls_gdld_nomark): Use tls_nomark_call predicate.  Set up operands
for indirect calls and correct length attr.

diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md
index 21791c51f2f..246452879a8 100644
--- a/gcc/config/rs6000/predicates.md
+++ b/gcc/config/rs6000/predicates.md
@@ -988,7 +988,12 @@ (define_predicate "rs6000_tls_symbol_ref"
 (define_predicate "unspec_tls"
   (match_code "unspec")
 {
-  return XINT (op, 1) == UNSPEC_TLSGD || XINT (op, 1) == UNSPEC_TLSLD;
+  if (XINT (op, 1) == UNSPEC_TLSGD)
+return REG_P (XVECEXP (op, 0, 1));
+  else if (XINT (op, 1) == UNSPEC_TLSLD)
+return REG_P (XVECEXP (op, 0, 0));
+  else
+return 0;
 })
 
 ;; Return 1 if the operand, used inside a MEM, is a valid first argument
@@ -1018,6 +1023,86 @@ (define_predicate "indirect_call_operand"
   return false;
 })
 
+;; Verify that elements of the tls_gdld_nomark call insn parallel past the
+;; second element (added to distinguish this call from normal calls) match
+;; the normal contours of a call insn.  This is necessary to prevent
+;; substitutions we don't want, for example, an indirect call being
+;; optimised to a direct call, or (set (reg:r2) (unspec [] UNSPEC_TOCSLOT))
+;; being cleverly optimised to (set (reg:r2) (reg:r2)) because gcc
+;; "knows" that r2 hasn't changed from a previous call.
+(define_predicate "tls_nomark_call"
+  (match_code "parallel")
+{
+  int n = XVECLEN (op, 0);
+  rtvec v = XVEC (op, 0);
+  rtx set = RTVEC_ELT (v, 0);
+  if (GET_CODE (set) != SET)
+return 0;
+  rtx call = XEXP (set, 1);
+  if (GET_CODE (call) != CALL)
+return 0;
+  rtx mem = XEXP (call, 0);
+  if (GET_CODE (mem) != MEM)
+return 0;
+  rtx addr = XEXP (mem, 0);
+  if (GET_CODE (addr) == SYMBOL_REF)
+{
+  if (DEFAULT_ABI == ABI_ELFv2 || DEFAULT_ABI == ABI_AIX)
+   return (n == 3 && GET_CODE (RTVEC_ELT (v, 2)) == CLOBBER
+   && REG_P (XEXP (RTVEC_ELT (v, 2), 0))
+   && REGNO (XEXP (RTVEC_ELT (v, 2), 0)) == LR_REGNO);
+  else if (DEFAULT_ABI == ABI_V4)
+   return (n >= 4 && n <= 5 && GET_CODE (RTVEC_ELT (v, 2)) == USE
+   && CONST_INT_P (XEXP (RTVEC_ELT (v, 2), 0))
+   && (INTVAL (XEXP (RTVEC_ELT (v, 2), 0)) & CALL_LONG) == 0
+   && (n == 4
+   || (GET_CODE (RTVEC_ELT (v, 3)) == USE
+   && REG_P (XEXP (RTVEC_ELT (v, 3), 0
+   && GET_CODE (RTVEC_ELT (v, n - 1)) == CLOBBER
+   && REG_P (XEXP (RTVEC_ELT (v, n - 1), 0))
+   && REGNO (XEXP (RTVEC_ELT (v, n - 1), 0)) == LR_REGNO);
+  else
+   gcc_unreachable ();
+}
+  else if (indirect_call_operand (addr, mode))
+{
+  if (DEFAULT_ABI == ABI_ELFv2)
+   return (n == 4 && GET_CODE (RTVEC_ELT (v, 2)) == SET
+   && REG_P (XEXP (RTVEC_ELT (v, 2), 0))
+   && REGNO (XEXP (RTVEC_ELT (v, 2), 0)) == TOC_REGNUM
+   && GET_CODE (XEXP (RTVEC_ELT (v, 2), 1)) == UNSPEC
+   && XINT (XEXP (RTVEC_ELT (v, 2), 1), 1) == UNSPEC_TOCSLOT
+   && XVECLEN (XEXP (RTVEC_ELT (v, 2), 1), 0) == 1
+   && CONST_INT_P (XVECEXP (XEXP (RTVEC_ELT (v, 2), 1), 0, 0))
+   && GET_CODE (RTVEC_ELT (v, 3)) == CLOBBER
+   && REG_P (XEXP (RTVEC_ELT (v, 3), 0))
+   && REGNO (XEXP (RTVEC_ELT (v, 3), 0)) == LR_REGNO);
+  else if (DEFAULT_ABI == ABI_AIX)
+   return (n == 5 && GET_CODE (RTVEC_ELT (v, 2)) == USE
+   && GET_CODE (XEXP (RTVEC_ELT (v, 2), 0)) == MEM
+   && GET_CO

Re: [PATCH] restore CFString handling in attribute format (PR 88638)

2019-01-06 Thread Martin Sebor

Attached is an updated patch with the wording change to the manual
discussed below and rebased on the top of today's trunk.

Martin

PS Thanks for the additional info, Iain.

On 1/5/19 10:53 AM, Iain Sandoe wrote:



On 5 Jan 2019, at 17:39, Martin Sebor  wrote:

On 1/5/19 3:31 AM, Iain Sandoe wrote:

Hi Martin,

On 4 Jan 2019, at 22:30, Mike Stump  wrote:

On Jan 4, 2019, at 2:03 PM, Martin Sebor  wrote:


The improved handling of attribute positional arguments added
in r266195 introduced a regression on Darwin where attribute
format with the CFString archetype accepts CFString* parameter
types in positions where only char* would otherwise be allowed.


You didn't ask Ok?  I'll assume you want a review...  The darwin bits and the 
testsuite bits look fine.


Index: gcc/doc/extend.texi
===
--- gcc/doc/extend.texi (revision 267580)
+++ gcc/doc/extend.texi (working copy)
@@ -22368,10 +22368,12 @@ bit-fields.  See the Solaris man page for @code{cm
  @node Darwin Format Checks
  @subsection Darwin Format Checks
  -Darwin targets support the @code{CFString} (or @code{__CFString__}) in the 
format
-attribute context.  Declarations made with such attribution are parsed for 
correct syntax
-and format argument types.  However, parsing of the format string itself is 
currently undefined
-and is not carried out by this version of the compiler.
+In addition to the full set of archetypes, Darwin targets also support
+the @code{CFString} (or @code{__CFString__}) archetype in the @code{format}
+attribute.  Declarations with this archetype are parsed for correct syntax
+and argument types.  However, parsing of the format string itself and
+validating arguments against it in calls to such functions is currently
+not performed.
Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} 
headers) may
  also be used as format arguments.  Note that the relevant headers are only 
likely to be


I find “archetype(s)” to be an usual (and possibly unfamiliar to many) word for 
this context.
how about:
s/archetype in/variant for the/
and then
  s/with this archetype/with this variant/
in the following sentence.
However, just 0.02GBP .. (fixing the fails is more important than bikeshedding 
the wording).


Thanks for chiming in!  I used archetype because that's the term
used in the attribute format specification to describe the first
argument.  I do tend to agree that archetype alone may not be
sufficiently familiar to all users.  I'm happy to add text to
make that clear.  Would you find the following better?

  In addition to the full set of format archetypes (attribute
  format style arguments such as @code{printf}, @code{scanf},
  @code{strftime}, and @code{strfmon}), Darwin targets also
  support the @code{CFString} (or @code{__CFString__}) archetype…


Yes, that makes is clearer

(as an aside, I think that to many people the meaning of archetype - as 
‘generic’  or ‘root example’
   etc  tends to come to mind before the ‘template/mold’ meaning … however 
couldn’t think of
  a better term that’s not already overloaded).


FWIW, I wanted to figure out how the CFString attribute made it
possible to differentiate between printf and scanf (and the other)
kinds of functions, for example, so I could add new tests for it,
but I couldn't tell that from the manual.  So I'm trying to update
the text to make it clear that although CFString is just like
the sprintf and scanf format arguments/archetypes, beyond
validating declarations that use it, the attribute serves no
functional purpose, so the printf/scanf distinction is moot.


The CFString container** is more general than our implementation, e.g. it 
should be able
to contain a variety of string formats (e.g. UTF etc.).   AFAIR at the time I 
implemented
it for FSF GCC (it was originally in the Apple Local branch), we didn’t have 
sufficient parsing
support for such things (and the support in the Apple-local branch didn’t look 
applicable).

If we do more sophisitcated checks, we probably need to take cognisance of the 
fact that a
fully-implemented CFString impl can have non-ascii payload.   I suspect 
(although honestly
it’s been a while, I maybe mis-remember) that was the reason I didn’t try to 
implement the
inspection at the time (if so, there’s probably a code comment to that effect).


Out of curiosity, is the attribute used for function call
validation by compilers other than GCC?  I couldn't find
anything online.


It used to be used for the platform GCC, when that was the “system compiler" 
(last edition
  apple 4.2.1) and I therefore assume it’s used by clang - but actually haven’t 
double-checked
at the time we added it - it was relevant.

Let’s revisit this in 10, and see if we can’t sync up with the platform 
expectations from the clang impl.

thanks for taking care of this,

Iain

** it’s actually a simple ObjectiveC object that happens to be supported by the 
CoreFoundation (C)
classes as

Remove overall growth from badness metrics

2019-01-06 Thread Jan Hubicka
Hi,
this patch removes overall growth from badness metrics.  This code was
added at a time inliner was purely function size based to give a hint
that inlining more different functions into all callers is better than
inlining one called very many times.

With profile we now have more fine grained information and in all
tests I did this heuristics seems to be counter-productive now and
harmful especially on large units where growth estimate gets out of
date.

I plan to commit the patch tomorrow after re-testing everything after
the bugfixes from today and yesterday.  In addition to this have found
that current inline-unit-growth is too small for LTO of large programs
(especially Firefox:) and there are important improvements when
increased from 20 to 30 or 40.  I am re-running C++ benchmarks and other
tests to decide about precise setting.  Finally I plan to increase
the new parameters for bit more inlining at -O2 and -Os.

Bootstrapped/regtested x86_64-linux, will commit it tomorrow.

* ipa-inline.c (edge_badness): Do not account overall_growth into
badness metrics.
Index: ipa-inline.c
===
--- ipa-inline.c(revision 267612)
+++ ipa-inline.c(working copy)
@@ -1082,8 +1082,8 @@ edge_badness (struct cgraph_edge *edge,
   /* When profile is available. Compute badness as:
  
  time_saved * caller_count
- goodness =  -
-growth_of_caller * overall_growth * combined_size
+ goodness =  
+growth_of_caller * combined_size
 
  badness = - goodness
 
@@ -1094,7 +1094,6 @@ edge_badness (struct cgraph_edge *edge,
   || caller->count.ipa ().nonzero_p ())
 {
   sreal numerator, denominator;
-  int overall_growth;
   sreal inlined_time = compute_inlined_call_time (edge, edge_time);
 
   numerator = (compute_uninlined_call_time (edge, unspec_edge_time)
@@ -1106,73 +1105,6 @@ edge_badness (struct cgraph_edge *edge,
   else if (caller->count.ipa ().initialized_p ())
numerator = numerator >> 11;
   denominator = growth;
-
-  overall_growth = callee_info->growth;
-
-  /* Look for inliner wrappers of the form:
-
-inline_caller ()
-  {
-do_fast_job...
-if (need_more_work)
-  noninline_callee ();
-  }
-Withhout panilizing this case, we usually inline noninline_callee
-into the inline_caller because overall_growth is small preventing
-further inlining of inline_caller.
-
-Penalize only callgraph edges to functions with small overall
-growth ...
-   */
-  if (growth > overall_growth
- /* ... and having only one caller which is not inlined ... */
- && callee_info->single_caller
- && !edge->caller->global.inlined_to
- /* ... and edges executed only conditionally ... */
- && edge->sreal_frequency () < 1
- /* ... consider case where callee is not inline but caller is ... */
- && ((!DECL_DECLARED_INLINE_P (edge->callee->decl)
-  && DECL_DECLARED_INLINE_P (caller->decl))
- /* ... or when early optimizers decided to split and edge
-frequency still indicates splitting is a win ... */
- || (callee->split_part && !caller->split_part
- && edge->sreal_frequency () * 100
-< PARAM_VALUE
- (PARAM_PARTIAL_INLINING_ENTRY_PROBABILITY)
- /* ... and do not overwrite user specified hints.   */
- && (!DECL_DECLARED_INLINE_P (edge->callee->decl)
- || DECL_DECLARED_INLINE_P (caller->decl)
-   {
- ipa_fn_summary *caller_info = ipa_fn_summaries->get (caller);
- int caller_growth = caller_info->growth;
-
- /* Only apply the penalty when caller looks like inline candidate,
-and it is not called once and.  */
- if (!caller_info->single_caller && overall_growth < caller_growth
- && caller_info->inlinable
- && caller_info->size
-< (DECL_DECLARED_INLINE_P (caller->decl)
-   ? MAX_INLINE_INSNS_SINGLE : MAX_INLINE_INSNS_AUTO))
-   {
- if (dump)
-   fprintf (dump_file,
-" Wrapper penalty. Increasing growth %i to %i\n",
-overall_growth, caller_growth);
- overall_growth = caller_growth;
-   }
-   }
-  if (overall_growth > 0)
-{
- /* Strongly preffer functions with few callers that can be inlined
-fully.  The square root here leads to smaller binaries at average.
-Watch however for extreme cases and return to linear function
-when growth is large.  */
- if (overall_growth < 256)
-  

Handle builtin_expect better in ipa-fnsummary

2019-01-06 Thread Jan Hubicka
Hi,
while analyzing Firefox I noticed that it uses builtin_expect quite
extensively and this sometimes causes ipa-predicates to be computed very
conservatively.  There are more possible improvements, but I will leave
it for stage1. This handles the common case where builtin_expect is
applied to parameter.

Bootstrapped/regtested x86_64-linux, will commit it later for tester to
catch up.

Honza

* ipa-fnsummary.c (builtin_expect_call_p, strip_copies): New function.
(unmodified_parm, unmodified_parm_or_parm_agg_item,
will_be_nonconstant_expr_predicate): Use it.
Index: ipa-fnsummary.c
===
--- ipa-fnsummary.c (revision 267610)
+++ ipa-fnsummary.c (working copy)
@@ -936,6 +936,57 @@ mark_modified (ao_ref *ao ATTRIBUTE_UNUS
   return true;
 }
 
+/* Return ture if STMT is builtin_expect on one of its variants.  */
+
+static bool
+builtin_expect_call_p (gimple *stmt)
+{
+  return ((gimple_call_builtin_p (stmt, BUILT_IN_EXPECT)
+  || gimple_call_builtin_p (stmt, BUILT_IN_EXPECT_WITH_PROBABILITY)
+  || gimple_call_internal_p (stmt, IFN_BUILTIN_EXPECT))
+ && gimple_call_num_args (stmt));
+}
+
+/* Walk to the original assignment to OP skipping wrapping noop casts,
+   builtin expectes etc.  */
+
+static tree
+strip_copies (tree op, gimple **stmt = NULL)
+{
+  STRIP_NOPS (op);
+  /* TODO: We should have some common way to tell if function returns its
+ argument.  */
+  if (TREE_CODE (op) == CALL_EXPR)
+{
+  tree fndecl = get_callee_fndecl (op);
+  if (!fndecl)
+   return op;
+  if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
+ && (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_EXPECT
+ || DECL_FUNCTION_CODE (fndecl)
+== BUILT_IN_EXPECT_WITH_PROBABILITY))
+   return strip_copies (CALL_EXPR_ARG (op, 0), stmt);
+  return op;
+}
+  if (TREE_CODE (op) == SSA_NAME
+  && builtin_expect_call_p (SSA_NAME_DEF_STMT (op)))
+{
+  if (stmt)
+   *stmt = SSA_NAME_DEF_STMT (op);
+  return strip_copies (gimple_call_arg (SSA_NAME_DEF_STMT (op), 0), stmt);
+}
+  if (TREE_CODE (op) == SSA_NAME
+  && !SSA_NAME_IS_DEFAULT_DEF (op)
+  && gimple_assign_single_p (SSA_NAME_DEF_STMT (op)))
+{
+  if (stmt)
+   *stmt = SSA_NAME_DEF_STMT (op);
+  return strip_copies (gimple_assign_rhs1 (SSA_NAME_DEF_STMT (op)),
+ stmt);
+}
+  return op;
+}
+
 /* If OP refers to value of function parameter, return the corresponding
parameter.  If non-NULL, the size of the memory load (or the SSA_NAME of the
PARM_DECL) will be stored to *SIZE_P in that case too.  */
@@ -979,16 +1030,10 @@ unmodified_parm_1 (gimple *stmt, tree op
 static tree
 unmodified_parm (gimple *stmt, tree op, HOST_WIDE_INT *size_p)
 {
+  op = strip_copies (op, &stmt);
   tree res = unmodified_parm_1 (stmt, op, size_p);
   if (res)
 return res;
-
-  if (TREE_CODE (op) == SSA_NAME
-  && !SSA_NAME_IS_DEFAULT_DEF (op)
-  && gimple_assign_single_p (SSA_NAME_DEF_STMT (op)))
-return unmodified_parm (SSA_NAME_DEF_STMT (op),
-   gimple_assign_rhs1 (SSA_NAME_DEF_STMT (op)),
-   size_p);
   return NULL_TREE;
 }
 
@@ -1005,6 +1050,7 @@ unmodified_parm_or_parm_agg_item (struct
  HOST_WIDE_INT *size_p,
  struct agg_position_info *aggpos)
 {
+  op = strip_copies (op, &stmt);
   tree res = unmodified_parm_1 (stmt, op, size_p);
 
   gcc_checking_assert (aggpos);
@@ -1450,12 +1496,13 @@ will_be_nonconstant_expr_predicate (stru
   nonconstant_names);
   return p2.or_with (summary->conds, p1);
 }
-  else if (TREE_CODE (expr) == CALL_EXPR)
-return true;
-  else
+  else 
 {
-  debug_tree (expr);
-  gcc_unreachable ();
+  tree expr2 = strip_copies (expr);
+  if (expr2 != expr)
+   return will_be_nonconstant_expr_predicate (info, summary, expr2,
+  nonconstant_names);
+  return true;
 }
   return false;
 }


Re: [PATCH, C++,rebased] Fix PR c++/88261

2019-01-06 Thread Martin Sebor

On 1/5/19 9:04 AM, Bernd Edlinger wrote:

On 1/4/19 10:22 PM, Jason Merrill wrote:

Hmm, I'm uncomfortable with starting to pass in the decl just for the sake of 
deciding whether this diagnostic should be a pedwarn or error. In general, 
because of copy elision, we can't know at this point what we're initializing, 
so I'd rather not pretend we can.  Instead, maybe add a 
LOOKUP_ALLOW_FLEXARY_INIT flag that you can add to the flags argument in the 
call from store_init_value?



Okay, I reworked the patch, to pass a bit in the flags, it was a bit more 
complicated
than anticipated, because it is necessary to pass the flag thru 
process_init_constructor
and friends to the recursive invocation of digest_init_r.  It turned out that
digest_nsdmi_init did not need to change, since it is always wrong to use 
flexarray init
there.  I added a new test case (flexary32.C) to exercises a few cases where 
non static
direct member intializers are allowed to use flexarrays (in static members) and 
where that
would be wrong (in automatic members).  So  that seems to work.


If that resolves pr69338 can you please also reference the bug in
the test and in the ChangeLog?  (Ditto for pr69697.)

Martin



New version of the patch is attached.

Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
Is it OK for trunk?


Thanks
Bernd.





[RS6000] Emit inline PLT when -mno-tls-markers

2019-01-06 Thread Alan Modra
I restricted output of inline PLT sequences to when TLS marker relocs
were also available, which is obviously true when just considering
assembler support.  However, there is a -mno-tls-markers option to
disable emitting the marker relocs.  Currently that option also
disables inline PLT sequences, which is a bug (*).  This patch fixes
that problem.

*) To be honest, it was a deliberate bug.  I didn't want to have to
deal with inline PLT __tls_get_addr sequences lacking the marker
relocs in the linker, but it turns out the existing linker support for
old-style __tls_get_addr calls works reasonably well.

Bootstrapped and regression tested powerpc64le-linux and
powerpc64-linux, with and without -mno-tls-markers.  OK to apply?

* config/rs6000/rs6000.c (rs6000_indirect_call_template_1),
(rs6000_pltseq_template): Guard output of TLS markers with
TARGET_TLS_MARKERS.
(rs6000_longcall_ref, rs6000_call_aix, rs6000_call_sysv),
(rs6000_sibcall_sysv): Ignore TARGET_TLS_MARKERS when deciding
to use inline PLT sequences.
* config/rs6000/rs6000.md (pltseq_tocsave_),
(pltseq_plt16_ha_, pltseq_plt16_lo_),
(pltseq_mtctr_): Don't test TARGET_TLS_MARKERS in predicate.

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 4e3c5fc135f..c126734d3e6 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -21618,7 +21618,7 @@ rs6000_indirect_call_template_1 (rtx *operands, 
unsigned int funop,
   const char *rel64 = TARGET_64BIT ? "64" : "";
   char tls[29];
   tls[0] = 0;
-  if (GET_CODE (operands[funop + 1]) == UNSPEC)
+  if (TARGET_TLS_MARKERS && GET_CODE (operands[funop + 1]) == UNSPEC)
{
  if (XINT (operands[funop + 1], 1) == UNSPEC_TLSGD)
sprintf (tls, ".reloc .,R_PPC%s_TLSGD,%%%u\n\t",
@@ -21707,7 +21707,7 @@ rs6000_pltseq_template (rtx *operands, int which)
   const char *rel64 = TARGET_64BIT ? "64" : "";
   char tls[28];
   tls[0] = 0;
-  if (GET_CODE (operands[3]) == UNSPEC)
+  if (TARGET_TLS_MARKERS && GET_CODE (operands[3]) == UNSPEC)
 {
   if (XINT (operands[3], 1) == UNSPEC_TLSGD)
sprintf (tls, ".reloc .,R_PPC%s_TLSGD,%%3\n\t",
@@ -32768,7 +32768,6 @@ rs6000_longcall_ref (rtx call_ref, rtx arg)
 }
 
   if (HAVE_AS_PLTSEQ
-  && TARGET_TLS_MARKERS
   && (DEFAULT_ABI == ABI_ELFv2 || DEFAULT_ABI == ABI_V4))
 {
   rtx base = const0_rtx;
@@ -37767,7 +37766,6 @@ rs6000_call_aix (rtx value, rtx func_desc, rtx tlsarg, 
rtx cookie)
   stack_toc_offset));
  MEM_VOLATILE_P (stack_toc_mem) = 1;
  if (HAVE_AS_PLTSEQ
- && TARGET_TLS_MARKERS
  && DEFAULT_ABI == ABI_ELFv2
  && GET_CODE (func_desc) == SYMBOL_REF)
{
@@ -37792,7 +37790,6 @@ rs6000_call_aix (rtx value, rtx func_desc, rtx tlsarg, 
rtx cookie)
 this insn for linker plt sequence editing too.  */
  func_addr = gen_rtx_REG (Pmode, CTR_REGNO);
  if (HAVE_AS_PLTSEQ
- && TARGET_TLS_MARKERS
  && GET_CODE (func_desc) == SYMBOL_REF)
{
  rtvec v = gen_rtvec (3, abi_reg, func_desc, tlsarg);
@@ -37933,8 +37930,7 @@ rs6000_call_sysv (rtx value, rtx func_desc, rtx tlsarg, 
rtx cookie)
   func = rs6000_longcall_ref (func_desc, tlsarg);
   /* If the longcall was implemented using PLT16 relocs, then r11
 needs to be valid at the call for lazy linking.  */
-  if (HAVE_AS_PLTSEQ
- && TARGET_TLS_MARKERS)
+  if (HAVE_AS_PLTSEQ)
abi_reg = func;
 }
 
@@ -37948,7 +37944,6 @@ rs6000_call_sysv (rtx value, rtx func_desc, rtx tlsarg, 
rtx cookie)
 this insn for linker plt sequence editing too.  */
   func_addr = gen_rtx_REG (Pmode, CTR_REGNO);
   if (HAVE_AS_PLTSEQ
- && TARGET_TLS_MARKERS
  && GET_CODE (func_desc) == SYMBOL_REF)
{
  rtvec v = gen_rtvec (3, func, func_desc, tlsarg);
@@ -38005,8 +38000,7 @@ rs6000_sibcall_sysv (rtx value, rtx func_desc, rtx 
tlsarg, rtx cookie)
   func = rs6000_longcall_ref (func_desc, tlsarg);
   /* If the longcall was implemented using PLT16 relocs, then r11
 needs to be valid at the call for lazy linking.  */
-  if (HAVE_AS_PLTSEQ
- && TARGET_TLS_MARKERS)
+  if (HAVE_AS_PLTSEQ)
abi_reg = func;
 }
 
@@ -38019,7 +38013,6 @@ rs6000_sibcall_sysv (rtx value, rtx func_desc, rtx 
tlsarg, rtx cookie)
 this insn for linker plt sequence editing too.  */
   func_addr = gen_rtx_REG (Pmode, CTR_REGNO);
   if (HAVE_AS_PLTSEQ
- && TARGET_TLS_MARKERS
  && GET_CODE (func_desc) == SYMBOL_REF)
{
  rtvec v = gen_rtvec (3, func, func_desc, tlsarg);
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 0d5ef31f9f2..58070447639 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000

[RS6000] Implement -mno-pltseq

2019-01-06 Thread Alan Modra
Since the last patch untangled inline PLT and TLS marker support there
now isn't a way of requesting the older long call sequences on a
compiler built with inline PLT support.  This patch adds support for
a new -mno-pltseq option.

Bootstrapped etc. powerpc64le-linux and powerpc64-linux.  OK?

* config/rs6000/rs6000.opt (mpltseq): New option.
* config/rs6000/rs6000.h (TARGET_PLTSEQ): Define.
* config/rs6000/rs6000.c (rs6000_option_override_internal): Error
if given -mpltseq when assembler support is lacking.
(rs6000_indirect_call_template_1, rs6000_longcall_ref),
(rs6000_call_aix, rs6000_call_sysv, rs6000_sibcall_sysv): Replace
uses of HAVE_AS_PLTSEQ with TARGET_PLTSEQ.
* config/rs6000/rs6000.md (pltseq_tocsave_),
(pltseq_plt16_ha_, pltseq_plt16_lo_),
(pltseq_mtctr_): Likewise.

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index c126734d3e6..e846e676810 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -4513,6 +4513,9 @@ rs6000_option_override_internal (bool global_init_p)
   if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET)
 rs6000_print_isa_options (stderr, 0, "after subtarget", rs6000_isa_flags);
 
+  if (global_options_set.x_rs6000_pltseq && TARGET_PLTSEQ != rs6000_pltseq)
+error ("%qs not supported by your assembler", "-mpltseq");
+
   rs6000_always_hint = (rs6000_tune != PROCESSOR_POWER4
&& rs6000_tune != PROCESSOR_POWER5
&& rs6000_tune != PROCESSOR_POWER6
@@ -21613,7 +21616,7 @@ rs6000_indirect_call_template_1 (rtx *operands, 
unsigned int funop,
|| (REG_P (operands[funop])
&& REGNO (operands[funop]) == LR_REGNO));
 
-  if (!TARGET_MACHO && HAVE_AS_PLTSEQ && GET_CODE (operands[funop]) == UNSPEC)
+  if (!TARGET_MACHO && TARGET_PLTSEQ && GET_CODE (operands[funop]) == UNSPEC)
 {
   const char *rel64 = TARGET_64BIT ? "64" : "";
   char tls[29];
@@ -32767,7 +32770,7 @@ rs6000_longcall_ref (rtx call_ref, rtx arg)
   call_ref = gen_rtx_SYMBOL_REF (VOIDmode, IDENTIFIER_POINTER (node));
 }
 
-  if (HAVE_AS_PLTSEQ
+  if (TARGET_PLTSEQ
   && (DEFAULT_ABI == ABI_ELFv2 || DEFAULT_ABI == ABI_V4))
 {
   rtx base = const0_rtx;
@@ -37765,7 +37768,7 @@ rs6000_call_aix (rtx value, rtx func_desc, rtx tlsarg, 
rtx cookie)
 gen_rtx_PLUS (Pmode, stack_ptr,
   stack_toc_offset));
  MEM_VOLATILE_P (stack_toc_mem) = 1;
- if (HAVE_AS_PLTSEQ
+ if (TARGET_PLTSEQ
  && DEFAULT_ABI == ABI_ELFv2
  && GET_CODE (func_desc) == SYMBOL_REF)
{
@@ -37789,7 +37792,7 @@ rs6000_call_aix (rtx value, rtx func_desc, rtx tlsarg, 
rtx cookie)
 calls via LR, so move the address there.  Needed to mark
 this insn for linker plt sequence editing too.  */
  func_addr = gen_rtx_REG (Pmode, CTR_REGNO);
- if (HAVE_AS_PLTSEQ
+ if (TARGET_PLTSEQ
  && GET_CODE (func_desc) == SYMBOL_REF)
{
  rtvec v = gen_rtvec (3, abi_reg, func_desc, tlsarg);
@@ -37930,7 +37933,7 @@ rs6000_call_sysv (rtx value, rtx func_desc, rtx tlsarg, 
rtx cookie)
   func = rs6000_longcall_ref (func_desc, tlsarg);
   /* If the longcall was implemented using PLT16 relocs, then r11
 needs to be valid at the call for lazy linking.  */
-  if (HAVE_AS_PLTSEQ)
+  if (TARGET_PLTSEQ)
abi_reg = func;
 }
 
@@ -37943,7 +37946,7 @@ rs6000_call_sysv (rtx value, rtx func_desc, rtx tlsarg, 
rtx cookie)
 calls via LR, so move the address there.  Needed to mark
 this insn for linker plt sequence editing too.  */
   func_addr = gen_rtx_REG (Pmode, CTR_REGNO);
-  if (HAVE_AS_PLTSEQ
+  if (TARGET_PLTSEQ
  && GET_CODE (func_desc) == SYMBOL_REF)
{
  rtvec v = gen_rtvec (3, func, func_desc, tlsarg);
@@ -38000,7 +38003,7 @@ rs6000_sibcall_sysv (rtx value, rtx func_desc, rtx 
tlsarg, rtx cookie)
   func = rs6000_longcall_ref (func_desc, tlsarg);
   /* If the longcall was implemented using PLT16 relocs, then r11
 needs to be valid at the call for lazy linking.  */
-  if (HAVE_AS_PLTSEQ)
+  if (TARGET_PLTSEQ)
abi_reg = func;
 }
 
@@ -38012,7 +38015,7 @@ rs6000_sibcall_sysv (rtx value, rtx func_desc, rtx 
tlsarg, rtx cookie)
   /* Indirect sibcalls must go via CTR.  Needed to mark
 this insn for linker plt sequence editing too.  */
   func_addr = gen_rtx_REG (Pmode, CTR_REGNO);
-  if (HAVE_AS_PLTSEQ
+  if (TARGET_PLTSEQ
  && GET_CODE (func_desc) == SYMBOL_REF)
{
  rtvec v = gen_rtvec (3, func, func_desc, tlsarg);
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index 9c0cc8de2b6..5ffa55e562c 100644
--- a/gcc/config/rs6000/rs6000.h
+++ 

[PATCH, libgfortran, committed] Make GFORTRAN_9 symbol node depend on GFORTRAN_8

2019-01-06 Thread Janne Blomqvist
At some point when the GFORTRAN_9 node was added it was forgotten to
make it depend on GFORTRAN_8. This patch fixes this.

Committed as obvious.

Index: ChangeLog
===
--- ChangeLog   (revision 267620)
+++ ChangeLog   (working copy)
@@ -1,3 +1,8 @@
+2019-01-07  Janne Blomqvist  
+
+   * gfortran.map (GFORTRAN_9): Make GFORTRAN_9 node depend on
+   GFORTRAN_8.
+
 2019-01-01  Jakub Jelinek  

Update copyright years.
Index: gfortran.map
===
--- gfortran.map(revision 267620)
+++ gfortran.map(working copy)
@@ -1578,4 +1578,4 @@ GFORTRAN_9 {
   __ieee_arithmetic_MOD_ieee_support_subnormal_4;
   __ieee_arithmetic_MOD_ieee_support_subnormal_8;
   __ieee_arithmetic_MOD_ieee_support_subnormal_noarg;
-};
+} GFORTRAN_8;


-- 
Janne Blomqvist


Re: [Patch] Bug 88521 - gcc 9.0 from r266355 miscompile x265 for mingw-w64 target

2019-01-06 Thread Martin Liška
On 12/29/18 2:30 AM, JonY wrote:
> On 12/26/18 1:10 PM, Lokesh Janghel wrote:
>> Hi,
>>
>> Here is the patch for the issue.
>> Please let me know your thoughts.
>>
>> On Fri, Dec 21, 2018 at 3:16 PM JonY <10wa...@gmail.com> wrote:
>>>
>>> On 12/21/18 9:08 AM, Uros Bizjak wrote:
 On Thu, Dec 20, 2018 at 1:09 PM Jakub Jelinek  wrote:
>
> On Thu, Dec 20, 2018 at 01:42:15PM +0530, Lokesh Janghel wrote:
>> Hi Mateuszb,
>>
>> I tested with your proposition patch and it is working right.
>> I also added the patch with test case.
>> Please let me know your thoughts/suggestions.
>
> ChangeLog entry is missing, please write it (and mention there
> Mateusz's name/mail as he wrote the i386.c part).
>
>>>
>>> Patch looks good to me, but please add a ChangeLog.
>>>
>>>
>>
>>
> 
> Changelog OK too.
> 

Thank for the fix, I installed that as r267622.

Martin