Re: GCC 9 backports

2020-10-16 Thread Martin Liška

On 10/2/20 1:15 PM, Martin Liška wrote:

On 10/2/20 12:05 PM, Martin Liška wrote:

There are 2 more I've just tested.

Martin


and one more.

Martin


Adding one more.

Martin
>From afcdd7b8ff51a7df885dc3fdf38be566a4c1fdbf Mon Sep 17 00:00:00 2001
From: Martin Liska 
Date: Thu, 15 Oct 2020 14:57:31 +0200
Subject: [PATCH] IPA: compare VRP types.

gcc/ChangeLog:

	PR ipa/97404
	* ipa-prop.c (struct ipa_vr_ggc_hash_traits):
	Compare types of VRP as we can merge ranges of different types.

gcc/testsuite/ChangeLog:

	PR ipa/97404
	* gcc.c-torture/execute/pr97404.c: New test.

(cherry picked from commit a86623902767122c71c7229150a8b8a79cbb3673)
---
 gcc/ipa-prop.c|  3 +-
 gcc/testsuite/gcc.c-torture/execute/pr97404.c | 28 +++
 2 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr97404.c

diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index 40edee7951c..7c8aee20a88 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -122,7 +122,8 @@ struct ipa_vr_ggc_hash_traits : public ggc_cache_remove 
   static bool
   equal (const value_range_base *a, const value_range_base *b)
 {
-  return a->equal_p (*b);
+  return (a->equal_p (*b)
+	  && types_compatible_p (a->type (), b->type ()));
 }
   static void
   mark_empty (value_range_base *)
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr97404.c b/gcc/testsuite/gcc.c-torture/execute/pr97404.c
new file mode 100644
index 000..7e5ce231725
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr97404.c
@@ -0,0 +1,28 @@
+/* PR ipa/97404 */
+/* { dg-additional-options "-fno-inline" } */
+
+char a, b;
+long c;
+short d, e;
+long *f = 
+int g;
+char h(signed char i) { return 0; }
+static short j(short i, int k) { return i < 0 ? 0 : i >> k; }
+void l(void);
+void m(void)
+{
+  e = j(d | 9766, 11);
+*f = e;
+}
+void l(void)
+{
+  a = 5 | g;
+b = h(a);
+}
+int main()
+{
+  m();
+  if (c != 4)
+__builtin_abort();
+  return 0;
+}
-- 
2.28.0



Re: GCC 9 backports

2020-10-15 Thread Martin Liška

On 10/2/20 1:15 PM, Martin Liška wrote:

On 10/2/20 12:05 PM, Martin Liška wrote:

There are 2 more I've just tested.

Martin


and one more.

Martin


and one more.

Martin
>From 12c9413228d2955126ff5c45194f8aacf1aa81f6 Mon Sep 17 00:00:00 2001
From: Martin Liska 
Date: Tue, 13 Oct 2020 16:44:47 +0200
Subject: [PATCH] IPA: fix profile handling in IRA

gcc/ChangeLog:

	PR ipa/97295
	* profile-count.c (profile_count::to_frequency): Move part of
	gcc_assert to STATIC_ASSERT.
	* regs.h (REG_FREQ_FROM_BB): Do not use count.to_frequency for
	a function that does not have count_max initialized.

(cherry picked from commit 508e2d88a4c512e8b8685cf5ba201ad48e6bb58d)
---
 gcc/profile-count.c | 4 ++--
 gcc/regs.h  | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/gcc/profile-count.c b/gcc/profile-count.c
index 8c58f8666f0..8d3340041fc 100644
--- a/gcc/profile-count.c
+++ b/gcc/profile-count.c
@@ -262,8 +262,8 @@ profile_count::to_frequency (struct function *fun) const
 return BB_FREQ_MAX;
   if (*this == profile_count::zero ())
 return 0;
-  gcc_assert (REG_BR_PROB_BASE == BB_FREQ_MAX
-	  && fun->cfg->count_max.initialized_p ());
+  STATIC_ASSERT (REG_BR_PROB_BASE == BB_FREQ_MAX);
+  gcc_assert (fun->cfg->count_max.initialized_p ());
   profile_probability prob = probability_in (fun->cfg->count_max);
   if (!prob.initialized_p ())
 return REG_BR_PROB_BASE;
diff --git a/gcc/regs.h b/gcc/regs.h
index 48b2e708160..2a19940281b 100644
--- a/gcc/regs.h
+++ b/gcc/regs.h
@@ -128,7 +128,8 @@ extern size_t reg_info_p_size;
or profile driven feedback is available and the function is never executed,
frequency is always equivalent.  Otherwise rescale the basic block
frequency.  */
-#define REG_FREQ_FROM_BB(bb) (optimize_function_for_size_p (cfun)	  \
+#define REG_FREQ_FROM_BB(bb) ((optimize_function_for_size_p (cfun)	  \
+			   || !cfun->cfg->count_max.initialized_p ()) \
 			  ? REG_FREQ_MAX  \
 			  : ((bb)->count.to_frequency (cfun)	  \
 * REG_FREQ_MAX / BB_FREQ_MAX)		  \
-- 
2.28.0



Re: GCC 9 backports

2020-10-02 Thread Martin Liška

On 10/2/20 12:05 PM, Martin Liška wrote:

There are 2 more I've just tested.

Martin


and one more.

Martin
>From e204fd5113a4ae92713442555ab4258abd84942a Mon Sep 17 00:00:00 2001
From: Martin Liska 
Date: Fri, 25 Sep 2020 10:53:26 +0200
Subject: [PATCH] GCOV: do not mangle .gcno files.

gcc/ChangeLog:

	PR gcov-profile/97193
	* coverage.c (coverage_init): GCDA note files should not be
	mangled and should end in output directory.

(cherry picked from commit f8dcbea5d2fb17dca3a7de97f15fc49997222365)
---
 gcc/coverage.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/gcc/coverage.c b/gcc/coverage.c
index 9be446a862d..c442e2fb008 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -1201,6 +1201,8 @@ coverage_obj_finish (vec *ctor)
 void
 coverage_init (const char *filename)
 {
+  const char *original_filename = filename;
+  int original_len = strlen (original_filename);
 #if HAVE_DOS_BASED_FILE_SYSTEM
   const char *separator = "\\";
 #else
@@ -1255,9 +1257,9 @@ coverage_init (const char *filename)
   /* Name of bbg file.  */
   if (flag_test_coverage && !flag_compare_debug)
 {
-  bbg_file_name = XNEWVEC (char, len + strlen (GCOV_NOTE_SUFFIX) + 1);
-  memcpy (bbg_file_name, filename, len);
-  strcpy (bbg_file_name + len, GCOV_NOTE_SUFFIX);
+  bbg_file_name = XNEWVEC (char, original_len + strlen (GCOV_NOTE_SUFFIX) + 1);
+  memcpy (bbg_file_name, original_filename, original_len);
+  strcpy (bbg_file_name + original_len, GCOV_NOTE_SUFFIX);
 
   if (!gcov_open (bbg_file_name, -1))
 	{
-- 
2.28.0



Re: GCC 9 backports

2020-10-02 Thread Martin Liška

There are 2 more I've just tested.

Martin
>From f070a482cf7b51716a9933302be246831ef0c236 Mon Sep 17 00:00:00 2001
From: Martin Liska 
Date: Thu, 1 Oct 2020 21:28:30 +0200
Subject: [PATCH] gcov: fix streaming of HIST_TYPE_IOR histogram type.

gcc/ChangeLog:

	PR gcov-profile/64636
	* value-prof.c (stream_out_histogram_value): Allow negative
	values for HIST_TYPE_IOR.

(cherry picked from commit 1921ebcaf6467996aede69e1bbe32400d8a20fe7)
---
 gcc/value-prof.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index 5013956cf86..b8ce4bd82ce 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -363,7 +363,10 @@ stream_out_histogram_value (struct output_block *ob, histogram_value hist)
   /* When user uses an unsigned type with a big value, constant converted
 	 to gcov_type (a signed type) can be negative.  */
   gcov_type value = hist->hvalue.counters[i];
-  if (hist->type == HIST_TYPE_SINGLE_VALUE && i == 0)
+  if ((hist->type == HIST_TYPE_SINGLE_VALUE && i == 0)
+	  || hist->type == HIST_TYPE_IOR)
+	/* Note that the IOR counter tracks pointer values and these can have
+	   sign bit set.  */
 	;
   else
 	gcc_assert (value >= 0);
-- 
2.28.0

>From fe9d9fcd2a643da4ec2c68525a551e074d9e11b6 Mon Sep 17 00:00:00 2001
From: Martin Liska 
Date: Mon, 21 Sep 2020 16:26:10 +0200
Subject: [PATCH] gcov: fix streaming corruption

gcc/ChangeLog:

	PR gcov-profile/97069
	* profile.c (branch_prob): Line number must be at least 1.

gcc/testsuite/ChangeLog:

	PR gcov-profile/97069
	* g++.dg/gcov/pr97069.C: New test.

(cherry picked from commit 6b4e8bf88f1172ce8561f57b12fb81063b21a78f)
---
 gcc/profile.c   |  6 +++---
 gcc/testsuite/g++.dg/gcov/pr97069.C | 20 
 2 files changed, 23 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/gcov/pr97069.C

diff --git a/gcc/profile.c b/gcc/profile.c
index a1dba1ac8fb..9ac3a7e93fe 100644
--- a/gcc/profile.c
+++ b/gcc/profile.c
@@ -1293,7 +1293,7 @@ branch_prob (bool thunk)
 	  seen_locations.add (loc);
 	  expanded_location curr_location = expand_location (loc);
 	  output_location (_locations, curr_location.file,
-			   curr_location.line, , bb);
+			   MAX (1, curr_location.line), , bb);
 	}
 
 	  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next ())
@@ -1304,7 +1304,7 @@ branch_prob (bool thunk)
 		{
 		  seen_locations.add (loc);
 		  output_location (_locations, gimple_filename (stmt),
-   gimple_lineno (stmt), , bb);
+   MAX (1, gimple_lineno (stmt)), , bb);
 		}
 	}
 
@@ -1319,7 +1319,7 @@ branch_prob (bool thunk)
 	{
 	  expanded_location curr_location = expand_location (loc);
 	  output_location (_locations, curr_location.file,
-			   curr_location.line, , bb);
+			   MAX (1, curr_location.line), , bb);
 	}
 
 	  if (offset)
diff --git a/gcc/testsuite/g++.dg/gcov/pr97069.C b/gcc/testsuite/g++.dg/gcov/pr97069.C
new file mode 100644
index 000..040e336662a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gcov/pr97069.C
@@ -0,0 +1,20 @@
+// PR gcov-profile/97069
+// { dg-options "--coverage" }
+// { dg-do run { target native } }
+
+# 0 "pr97069.C"
+# 0 ""
+# 0 ""
+# 1 "/usr/include/stdc-predef.h" 1 3 4
+# 0 "" 2
+# 1 "pr97069.C"
+int main()
+{
+  return 0;
+}
+# 0 "pr97069.C"
+void zero_line_directive()
+{
+}
+
+// { dg-final { run-gcov pr97069.C } }
-- 
2.28.0



Re: GCC 9 backports

2020-04-20 Thread Martin Liška

On 4/3/20 12:32 PM, Martin Liška wrote:

Hi.

There's one more I've tested.

Martin


And one more.

Martin
>From 6db982d1cfccbde2a5812edf82ad330cf327bc23 Mon Sep 17 00:00:00 2001
From: Martin Liska 
Date: Fri, 17 Apr 2020 09:33:05 +0200
Subject: [PATCH] Backport e9f799d25973fc38022c5ea71ed5a2bca58a847f

ChangeLog:

2020-04-17  Martin Liska  
	Jonathan Yong <10wa...@gmail.com>

	PR gcov-profile/94570
	* ltmain.sh: Do not define HAVE_DOS_BASED_FILE_SYSTEM
	for CYGWIN.

gcc/ChangeLog:

2020-04-17  Martin Liska  
	Jonathan Yong <10wa...@gmail.com>

	PR gcov-profile/94570
	* coverage.c (coverage_init): Use separator properly.

include/ChangeLog:

2020-04-17  Martin Liska  
	Jonathan Yong <10wa...@gmail.com>

	PR gcov-profile/94570
	* filenames.h (defined): Do not define HAVE_DOS_BASED_FILE_SYSTEM
	for CYGWIN.
---
 gcc/coverage.c  | 12 ++--
 include/filenames.h |  3 ++-
 ltmain.sh   |  4 ++--
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/gcc/coverage.c b/gcc/coverage.c
index 1ffefd5f482..9be446a862d 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -1201,6 +1201,11 @@ coverage_obj_finish (vec *ctor)
 void
 coverage_init (const char *filename)
 {
+#if HAVE_DOS_BASED_FILE_SYSTEM
+  const char *separator = "\\";
+#else
+  const char *separator = "/";
+#endif
   int len = strlen (filename);
   int prefix_len = 0;
 
@@ -1217,11 +1222,6 @@ coverage_init (const char *filename)
 	 of filename in order to prevent file path clashing.  */
   if (profile_data_prefix)
 	{
-#if HAVE_DOS_BASED_FILE_SYSTEM
-	  const char *separator = "\\";
-#else
-	  const char *separator = "/";
-#endif
 	  filename = concat (getpwd (), separator, filename, NULL);
 	  filename = mangle_path (filename);
 	  len = strlen (filename);
@@ -1240,7 +1240,7 @@ coverage_init (const char *filename)
   if (profile_data_prefix)
 {
   memcpy (da_file_name, profile_data_prefix, prefix_len);
-  da_file_name[prefix_len++] = '/';
+  da_file_name[prefix_len++] = *separator;
 }
   memcpy (da_file_name + prefix_len, filename, len);
   strcpy (da_file_name + prefix_len + len, GCOV_DATA_SUFFIX);
diff --git a/include/filenames.h b/include/filenames.h
index 1bcfddb87ac..790a27db873 100644
--- a/include/filenames.h
+++ b/include/filenames.h
@@ -32,7 +32,8 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
 extern "C" {
 #endif
 
-#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__)
+#if defined(__MSDOS__) || (defined(_WIN32) && ! defined(__CYGWIN__)) || \
+defined(__OS2__)
 #  ifndef HAVE_DOS_BASED_FILE_SYSTEM
 #define HAVE_DOS_BASED_FILE_SYSTEM 1
 #  endif
diff --git a/ltmain.sh b/ltmain.sh
index 79f9ba89af5..70990740b6c 100644
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -3425,8 +3425,8 @@ int setenv (const char *, const char *, int);
 # define PATH_SEPARATOR ':'
 #endif
 
-#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
-  defined (__OS2__)
+#if (defined (_WIN32) && ! defined(__CYGWIN__)) || defined (__MSDOS__) || \
+  defined (__DJGPP__) || defined (__OS2__)
 # define HAVE_DOS_BASED_FILE_SYSTEM
 # define FOPEN_WB "wb"
 # ifndef DIR_SEPARATOR_2
-- 
2.26.0



Re: GCC 9 backports

2020-04-03 Thread Martin Liška

Hi.

There's one more I've tested.

Martin
>From 3b64f64f036c03e74fc4b55327cc07dc1dc21116 Mon Sep 17 00:00:00 2001
From: Martin Liska 
Date: Fri, 3 Apr 2020 09:39:10 +0200
Subject: [PATCH] Backport 55a7380213a5c16120d5c674fb42b38a3d796b57

gcc/ChangeLog:

2020-04-03  Martin Liska  

	PR ipa/94445
	* ipa-icf-gimple.c (func_checker::compare_gimple_call):
	  Compare type attributes for gimple_call_fntypes.
---
 gcc/ipa-icf-gimple.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c
index 25284936bc3..38e0ac12f7e 100644
--- a/gcc/ipa-icf-gimple.c
+++ b/gcc/ipa-icf-gimple.c
@@ -37,6 +37,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "ipa-utils.h"
 #include "tree-eh.h"
 #include "builtins.h"
+#include "attribs.h"
 
 #include "ipa-icf-gimple.h"
 
@@ -768,6 +769,9 @@ func_checker::compare_gimple_call (gcall *s1, gcall *s2)
   || (fntype1 && !types_compatible_p (fntype1, fntype2)))
 return return_false_with_msg ("call function types are not compatible");
 
+  if (fntype1 && fntype2 && comp_type_attributes (fntype1, fntype2) != 1)
+return return_false_with_msg ("different fntype attributes");
+
   tree chain1 = gimple_call_chain (s1);
   tree chain2 = gimple_call_chain (s2);
   if ((chain1 && !chain2)
-- 
2.26.0



Re: GCC 9 backports

2020-03-10 Thread Martin Liška

Hi.

One more that I've just tested.

Martin
>From 40b6c70febc36e523caf9d8615fa4e1e1d68508b Mon Sep 17 00:00:00 2001
From: Martin Liska 
Date: Mon, 9 Mar 2020 14:13:04 +0100
Subject: [PATCH] Backport 314b91220a07bd63f13c58e37f1b5b9430a3702b

gcc/ChangeLog:

2020-03-09  Martin Liska  

	PR target/93800
	* config/rs6000/rs6000.c (rs6000_option_override_internal):
	Remove set of str_align_loops and str_align_jumps as these
	should be set in previous 2 conditions in the function.

gcc/testsuite/ChangeLog:

2020-03-09  Martin Liska  

	PR target/93800
	* gcc.target/powerpc/pr93800.c: New test.
---
 gcc/config/rs6000/rs6000.c |  5 -
 gcc/testsuite/gcc.target/powerpc/pr93800.c | 14 ++
 2 files changed, 14 insertions(+), 5 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/powerpc/pr93800.c

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 87d60078bb0..d45294302cb 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -4715,11 +4715,6 @@ rs6000_option_override_internal (bool global_init_p)
 		  str_align_loops = "16";
 		}
 	}
-
-	  if (flag_align_jumps && !str_align_jumps)
-	str_align_jumps = "16";
-	  if (flag_align_loops && !str_align_loops)
-	str_align_loops = "16";
 	}
 
   /* Arrange to save and restore machine status around nested functions.  */
diff --git a/gcc/testsuite/gcc.target/powerpc/pr93800.c b/gcc/testsuite/gcc.target/powerpc/pr93800.c
new file mode 100644
index 000..f8dfbe7c082
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr93800.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mcpu=860 -O2" } */
+/* { dg-require-effective-target ilp32 } */
+/* { dg-final { scan-assembler-not "\\.p2align 4" } } */
+
+volatile int g;
+int f(int a, int b)
+{
+	int i;
+
+	for (i = 0; i < b; i++)
+		a += g;
+	return a;
+}
-- 
2.25.1



Re: GCC 9 backports

2020-02-28 Thread Martin Liška

On 10/23/19 2:11 PM, Martin Liška wrote:

On 9/2/19 10:56 AM, Martin Liška wrote:

Hi.

There are 2 more patches that I've just tested.

Martin


Hi.

There are 2 more patches that I've just tested.

Martin



Hi.

There's one more patch.

Martin
>From 08bf7bde9f2987b1c623d272cc71fc14a1622442 Mon Sep 17 00:00:00 2001
From: Martin Liska 
Date: Fri, 28 Feb 2020 17:52:57 +0100
Subject: Backport 08bf7bde9f2987b1c623d272cc71fc14a1622442

gcc/ChangeLog:

2020-02-28  Martin Liska  

	PR other/93965
	* configure.ac: Improve detection of ld_date by requiring
	either two dashes or none.
	* configure: Regenerate.

---
diff --git a/gcc/configure b/gcc/configure
index f55cdb8c77f..5381e107bce 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -23384,7 +23384,7 @@ if test $in_tree_ld != yes ; then
   ld_vers=`echo $ld_ver | sed -n \
 	  -e 's,^.*[	 ]\([0-9][0-9]*\.[0-9][0-9]*.*\)$,\1,p'`
 fi
-ld_date=`echo $ld_ver | sed -n 's,^.*\([2-9][0-9][0-9][0-9]\)[-]*\([01][0-9]\)[-]*\([0-3][0-9]\).*$,\1\2\3,p'`
+ld_date=`echo $ld_ver | sed -n 's,^.*\([2-9][0-9][0-9][0-9]\)\(-*\)\([01][0-9]\)\2\([0-3][0-9]\).*$,\1\3\4,p'`
 ld_vers_major=`expr "$ld_vers" : '\([0-9]*\)'`
 ld_vers_minor=`expr "$ld_vers" : '[0-9]*\.\([0-9]*\)'`
 ld_vers_patch=`expr "$ld_vers" : '[0-9]*\.[0-9]*\.\([0-9]*\)'`
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 0e6e475950d..0d6230e0ca1 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -2804,7 +2804,7 @@ if test $in_tree_ld != yes ; then
   ld_vers=`echo $ld_ver | sed -n \
 	  -e 's,^.*[	 ]\([0-9][0-9]*\.[0-9][0-9]*.*\)$,\1,p'`
 fi
-ld_date=`echo $ld_ver | sed -n 's,^.*\([2-9][0-9][0-9][0-9]\)[-]*\([01][0-9]\)[-]*\([0-3][0-9]\).*$,\1\2\3,p'`
+ld_date=`echo $ld_ver | sed -n 's,^.*\([2-9][0-9][0-9][0-9]\)\(-*\)\([01][0-9]\)\2\([0-3][0-9]\).*$,\1\3\4,p'`
 ld_vers_major=`expr "$ld_vers" : '\([0-9]*\)'`
 ld_vers_minor=`expr "$ld_vers" : '[0-9]*\.\([0-9]*\)'`
 ld_vers_patch=`expr "$ld_vers" : '[0-9]*\.[0-9]*\.\([0-9]*\)'`
--
2.25.0


Re: GCC 9 backports

2019-10-23 Thread Martin Liška
On 9/2/19 10:56 AM, Martin Liška wrote:
> Hi.
> 
> There are 2 more patches that I've just tested.
> 
> Martin

Hi.

There are 2 more patches that I've just tested.

Martin
>From e1299829fce26b60105e09e2c6e60d8b998a566b Mon Sep 17 00:00:00 2001
From: jakub 
Date: Fri, 27 Sep 2019 10:28:48 +
Subject: [PATCH 2/2] Backport r276178

gcc/ChangeLog:

	* tree-vectorizer.c (try_vectorize_loop_1): Add
	TODO_update_ssa_only_virtuals similarly to what slp pass does.

gcc/testsuite/ChangeLog:

2019-09-27  Jakub Jelinek  

	PR tree-optimization/91885
	* gcc.dg/pr91885.c (__int64_t): Change from long to long long.
	(__uint64_t): Change from unsigned long to unsigned long long.
---
 gcc/testsuite/gcc.dg/pr91885.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/pr91885.c b/gcc/testsuite/gcc.dg/pr91885.c
index 934e8d3e6c3..35be32be559 100644
--- a/gcc/testsuite/gcc.dg/pr91885.c
+++ b/gcc/testsuite/gcc.dg/pr91885.c
@@ -2,8 +2,8 @@
 /* { dg-options "-O3 -fprofile-generate" } */
 /* { dg-require-profiling "-fprofile-generate" } */
 
-typedef signed long int __int64_t;
-typedef unsigned long int __uint64_t;
+typedef signed long long int __int64_t;
+typedef unsigned long long int __uint64_t;
 typedef __int64_t int64_t;
 typedef __uint64_t uint64_t;
 inline void
-- 
2.23.0

>From 2f9a827e2f8b675ae18a9e192a80855ac41f4aaa Mon Sep 17 00:00:00 2001
From: marxin 
Date: Thu, 26 Sep 2019 07:40:09 +
Subject: [PATCH 1/2] Backport r276141

gcc/ChangeLog:

2019-09-26  Martin Liska  

	PR tree-optimization/91885
	* tree-vectorizer.c (try_vectorize_loop_1):
	Add TODO_update_ssa_only_virtuals similarly to what slp
	pass does.

gcc/testsuite/ChangeLog:

2019-09-26  Martin Liska  

	PR tree-optimization/91885
	* gcc.dg/pr91885.c: New test.
---
 gcc/testsuite/gcc.dg/pr91885.c | 47 ++
 gcc/tree-vectorizer.c  |  2 +-
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr91885.c

diff --git a/gcc/testsuite/gcc.dg/pr91885.c b/gcc/testsuite/gcc.dg/pr91885.c
new file mode 100644
index 000..934e8d3e6c3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr91885.c
@@ -0,0 +1,47 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fprofile-generate" } */
+/* { dg-require-profiling "-fprofile-generate" } */
+
+typedef signed long int __int64_t;
+typedef unsigned long int __uint64_t;
+typedef __int64_t int64_t;
+typedef __uint64_t uint64_t;
+inline void
+BLI_endian_switch_int64 (int64_t *val)
+{
+  uint64_t tval = *val;
+  *val = ((tval >> 56)) | ((tval << 40) & 0x00ffll)
+	 | ((tval << 24) & 0xff00ll)
+	 | ((tval << 8) & 0x00ffll)
+	 | ((tval >> 8) & 0xff00ll)
+	 | ((tval >> 24) & 0x00ffll)
+	 | ((tval >> 40) & 0xff00ll) | ((tval << 56));
+}
+typedef struct anim_index_entry
+{
+  unsigned long long seek_pos_dts;
+  unsigned long long pts;
+} anim_index_entry;
+extern struct anim_index_entry *
+MEM_callocN (int);
+struct anim_index
+{
+  int num_entries;
+  struct anim_index_entry *entries;
+};
+struct anim_index *
+IMB_indexer_open (const char *name)
+{
+  char header[13];
+  struct anim_index *idx;
+  int i;
+  idx->entries = MEM_callocN (8);
+  if (((1 == 0) != (header[8] == 'V')))
+{
+  for (i = 0; i < idx->num_entries; i++)
+	{
+	  BLI_endian_switch_int64 ((int64_t *) >entries[i].seek_pos_dts);
+	  BLI_endian_switch_int64 ((int64_t *) >entries[i].pts);
+	}
+}
+}
diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c
index d27104933a9..d89ec3b7c76 100644
--- a/gcc/tree-vectorizer.c
+++ b/gcc/tree-vectorizer.c
@@ -941,7 +941,7 @@ try_vectorize_loop_1 (hash_table *_to_vf_htab,
 	  fold_loop_internal_call (loop_vectorized_call,
    boolean_true_node);
 	  loop_vectorized_call = NULL;
-	  ret |= TODO_cleanup_cfg;
+	  ret |= TODO_cleanup_cfg | TODO_update_ssa_only_virtuals;
 	}
 	}
   /* If outer loop vectorization fails for LOOP_VECTORIZED guarded
-- 
2.23.0



Re: GCC 9 backports

2019-09-02 Thread Martin Liška
Hi.

There are 2 more patches that I've just tested.

Martin
>From 367c03f190d78f1811715b4158ccff9c9aa08a1a Mon Sep 17 00:00:00 2001
From: marxin 
Date: Mon, 2 Sep 2019 07:06:54 +
Subject: [PATCH 1/2] Backport r275291

gcc/ChangeLog:

2019-09-02  Martin Liska  

	PR gcov-profile/91601
	* gcov.c (path_contains_zero_cycle_arc): Rename to ...
	(path_contains_zero_or_negative_cycle_arc): ... this and handle
	also negative edges.
	(circuit): Handle also negative edges as they can happen
	in some situations.
---
 gcc/gcov.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/gcov.c b/gcc/gcov.c
index b06a6714c2e..7e51c2efb30 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -725,10 +725,10 @@ unblock (const block_info *u, block_vector_t ,
 /* Return true when PATH contains a zero cycle arc count.  */
 
 static bool
-path_contains_zero_cycle_arc (arc_vector_t )
+path_contains_zero_or_negative_cycle_arc (arc_vector_t )
 {
   for (unsigned i = 0; i < path.size (); i++)
-if (path[i]->cs_count == 0)
+if (path[i]->cs_count <= 0)
   return true;
   return false;
 }
@@ -754,7 +754,7 @@ circuit (block_info *v, arc_vector_t , block_info *start,
 {
   block_info *w = arc->dst;
   if (w < start
-	  || arc->cs_count == 0
+	  || arc->cs_count <= 0
 	  || !linfo.has_block (w))
 	continue;
 
@@ -765,7 +765,7 @@ circuit (block_info *v, arc_vector_t , block_info *start,
 	  handle_cycle (path, count);
 	  loop_found = true;
 	}
-  else if (!path_contains_zero_cycle_arc (path)
+  else if (!path_contains_zero_or_negative_cycle_arc (path)
 	   &&  find (blocked.begin (), blocked.end (), w) == blocked.end ())
 	loop_found |= circuit (w, path, start, blocked, block_lists, linfo,
 			   count);
@@ -780,7 +780,7 @@ circuit (block_info *v, arc_vector_t , block_info *start,
   {
 	block_info *w = arc->dst;
 	if (w < start
-	|| arc->cs_count == 0
+	|| arc->cs_count <= 0
 	|| !linfo.has_block (w))
 	  continue;
 
-- 
2.23.0

>From f4e0d3156d4c1e651caf2e796df5a10d4619b6eb Mon Sep 17 00:00:00 2001
From: marxin 
Date: Mon, 2 Sep 2019 07:07:11 +
Subject: [PATCH 2/2] Backport r275292

gcc/c-family/ChangeLog:

2019-09-02  Martin Liska  

	PR c++/91155
	* c-common.c (fname_as_string): Use cxx_printable_name for
	__PRETTY_FUNCTION__ same as was used before r265711.

gcc/testsuite/ChangeLog:

2019-09-02  Martin Liska  

	PR c++/91155
	* g++.dg/torture/pr91155.C: New test.
---
 gcc/cp/decl.c  | 20 +---
 gcc/testsuite/g++.dg/torture/pr91155.C | 18 ++
 2 files changed, 35 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/torture/pr91155.C

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 05ceda89d4c..e860f26e55d 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4474,13 +4474,27 @@ cp_fname_init (const char* name, tree *type_p)
 static tree
 cp_make_fname_decl (location_t loc, tree id, int type_dep)
 {
-  const char *const name = (type_dep && in_template_function ()
-			? NULL : fname_as_string (type_dep));
+  const char * name = NULL;
+  bool release_name = false;
+  if (!(type_dep && in_template_function ()))
+{
+  if (current_function_decl == NULL_TREE)
+	name = "top level";
+  else if (type_dep == 1) /* __PRETTY_FUNCTION__ */
+	name = cxx_printable_name (current_function_decl, 2);
+  else if (type_dep == 0) /* __FUNCTION__ */
+	{
+	  name = fname_as_string (type_dep);
+	  release_name = true;
+	}
+  else
+	gcc_unreachable ();
+}
   tree type;
   tree init = cp_fname_init (name, );
   tree decl = build_decl (loc, VAR_DECL, id, type);
 
-  if (name)
+  if (release_name)
 free (CONST_CAST (char *, name));
 
   /* As we're using pushdecl_with_scope, we must set the context.  */
diff --git a/gcc/testsuite/g++.dg/torture/pr91155.C b/gcc/testsuite/g++.dg/torture/pr91155.C
new file mode 100644
index 000..04e4f7ab41b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr91155.C
@@ -0,0 +1,18 @@
+/* PR c++/91155.  */
+
+template< char C > struct dummy {};
+
+template< typename T > const char *test()
+{
+  __builtin_printf ("test: %s\n", __PRETTY_FUNCTION__);
+  return __PRETTY_FUNCTION__;
+}
+
+int main()
+{
+if (__builtin_strcmp ("const char* test() [with T = dummy<\'\\000\'>]", test< dummy< '\0' > > ()) != 0)
+{};//  __builtin_abort ();
+if (__builtin_strcmp ("const char* test() [with T = dummy<\'\\\'\'>]", test< dummy< '\'' > > ()) != 0)
+{};//  __builtin_abort ();
+return 0;
+}
-- 
2.23.0



Re: GCC 9 backports

2019-08-23 Thread Martin Liška
There are 3 more tested patches that I going to backport.

Martin
>From a413f183a85bc9a08e3dcd9e9d617086fce86460 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Thu, 15 Aug 2019 06:58:36 +
Subject: [PATCH 3/3] Backport r274504

gcc/ChangeLog:

2019-08-15  Martin Liska  

	PR ipa/91438
	* cgraph.c (cgraph_node::remove): When setting
	n->origin = NULL for all nested functions, reset
	also next_nested.
---
 gcc/cgraph.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index d9e7353bd7b..1febb6369a0 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -1779,8 +1779,6 @@ cgraph_node::release_body (bool keep_arguments)
 void
 cgraph_node::remove (void)
 {
-  cgraph_node *n;
-
   if (symtab->ipa_clones_dump_file && symtab->cloned_nodes.contains (this))
 fprintf (symtab->ipa_clones_dump_file,
 	 "Callgraph removal;%s;%d;%s;%d;%d\n", asm_name (), order,
@@ -1797,8 +1795,13 @@ cgraph_node::remove (void)
  */
   force_output = false;
   forced_by_abi = false;
-  for (n = nested; n; n = n->next_nested)
+  cgraph_node *next = nested;
+  for (cgraph_node *n = nested; n; n = next)
+  {
+next = n->next_nested;
 n->origin = NULL;
+n->next_nested = NULL;
+  }
   nested = NULL;
   if (origin)
 {
@@ -1852,7 +1855,7 @@ cgraph_node::remove (void)
  */
   if (symtab->state != LTO_STREAMING)
 {
-  n = cgraph_node::get (decl);
+  cgraph_node *n = cgraph_node::get (decl);
   if (!n
 	  || (!n->clones && !n->clone_of && !n->global.inlined_to
 	  && ((symtab->global_info_ready || in_lto_p)
-- 
2.22.1

>From 7fad5cd74a282bc49b14c4d9a5a95b3d1a212394 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Thu, 15 Aug 2019 06:58:26 +
Subject: [PATCH 2/3] Backport r274503

gcc/ChangeLog:

2019-08-15  Martin Liska  

	* cgraph.c (cgraph_node::verify_node): Verify origin, nested
	and next_nested.
---
 gcc/cgraph.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index db4c9c747b9..d9e7353bd7b 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -3449,6 +3449,30 @@ cgraph_node::verify_node (void)
 	  e->aux = 0;
 	}
 }
+
+  if (nested != NULL)
+{
+  for (cgraph_node *n = nested; n != NULL; n = n->next_nested)
+	{
+	  if (n->origin == NULL)
+	{
+	  error ("missing origin for a node in a nested list");
+	  error_found = true;
+	}
+	  else if (n->origin != this)
+	{
+	  error ("origin points to a different parent");
+	  error_found = true;
+	  break;
+	}
+	}
+}
+  if (next_nested != NULL && origin == NULL)
+{
+  error ("missing origin for a node in a nested list");
+  error_found = true;
+}
+
   if (error_found)
 {
   dump (stderr);
-- 
2.22.1

>From ebcb363be811c20d678dc7b985e68ca86afe4707 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Thu, 15 Aug 2019 06:58:09 +
Subject: [PATCH 1/3] Backport r274502

gcc/ChangeLog:

2019-08-15  Martin Liska  

	PR ipa/91404
	* passes.c (order): Remove.
	(uid_hash_t): Likewise).
	(remove_cgraph_node_from_order): Remove from set
	of pointers (cgraph_node *).
	(insert_cgraph_node_to_order): New.
	(duplicate_cgraph_node_to_order): New.
	(do_per_function_toporder): Register all 3 cgraph hooks.
	Skip removed_nodes now as we know about all of them.
---
 gcc/passes.c | 68 +---
 1 file changed, 43 insertions(+), 25 deletions(-)

diff --git a/gcc/passes.c b/gcc/passes.c
index d8d479a1c17..092dafbd488 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -1646,24 +1646,39 @@ do_per_function (void (*callback) (function *, void *data), void *data)
 }
 }
 
-/* Because inlining might remove no-longer reachable nodes, we need to
-   keep the array visible to garbage collector to avoid reading collected
-   out nodes.  */
-static int nnodes;
-static GTY ((length ("nnodes"))) cgraph_node **order;
-
-#define uid_hash_t hash_set >
-
 /* Hook called when NODE is removed and therefore should be
excluded from order vector.  DATA is a hash set with removed nodes.  */
 
 static void
 remove_cgraph_node_from_order (cgraph_node *node, void *data)
 {
-  uid_hash_t *removed_nodes = (uid_hash_t *)data;
-  removed_nodes->add (node->get_uid ());
+  hash_set *removed_nodes = (hash_set *)data;
+  removed_nodes->add (node);
+}
+
+/* Hook called when NODE is insert and therefore should be
+   excluded from removed_nodes.  DATA is a hash set with removed nodes.  */
+
+static void
+insert_cgraph_node_to_order (cgraph_node *node, void *data)
+{
+  hash_set *removed_nodes = (hash_set *)data;
+  removed_nodes->remove (node);
 }
 
+/* Hook called when NODE is duplicated and therefore should be
+   excluded from removed_nodes.  DATA is a hash set with removed nodes.  */
+
+static void
+duplicate_cgraph_node_to_order (cgraph_node *node, cgraph_node *node2,
+void *data)
+{
+  hash_set *removed_nodes = (hash_set *)data;
+  gcc_checking_assert (!removed_nodes->contains 

Re: GCC 9 backports

2019-07-22 Thread Martin Liška
Hi.

One more patch I've just tested.

Martin
>From eb62ef9ec1edc109aa69137ed077620cafad5253 Mon Sep 17 00:00:00 2001
From: Martin Liska 
Date: Mon, 22 Jul 2019 10:00:07 +0200
Subject: [PATCH] Backport r273660

gcc/ChangeLog:

2019-07-22  Martin Liska  

	PR driver/91172
	* opts-common.c (decode_cmdline_option): Decode
	argument of -Werror and check it for a wrong language.
	* opts-global.c (complain_wrong_lang): Remove such case.

gcc/testsuite/ChangeLog:

2019-07-22  Martin Liska  

	PR driver/91172
	* gcc.dg/pr91172.c: New test.
---
 gcc/opts-common.c | 20 +++-
 gcc/opts-global.c |  6 +-
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index 3c2553368ac..9b0d76d1148 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -438,7 +438,8 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask,
 
   extra_args = 0;
 
-  opt_index = find_opt (argv[0] + 1, lang_mask);
+  const char *opt_value = argv[0] + 1;
+  opt_index = find_opt (opt_value, lang_mask);
   i = 0;
   while (opt_index == OPT_SPECIAL_unknown
 	 && i < ARRAY_SIZE (option_map))
@@ -641,6 +642,23 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask,
   /* Check if this is a switch for a different front end.  */
   if (!option_ok_for_language (option, lang_mask))
 errors |= CL_ERR_WRONG_LANG;
+  else if (strcmp (option->opt_text, "-Werror=") == 0
+	   && strchr (opt_value, ',') == NULL)
+{
+  /* Verify that -Werror argument is a valid warning
+	 for a language.  */
+  char *werror_arg = xstrdup (opt_value + 6);
+  werror_arg[0] = 'W';
+
+  size_t warning_index = find_opt (werror_arg, lang_mask);
+  if (warning_index != OPT_SPECIAL_unknown)
+	{
+	  const struct cl_option *warning_option
+	= _options[warning_index];
+	  if (!option_ok_for_language (warning_option, lang_mask))
+	errors |= CL_ERR_WRONG_LANG;
+	}
+}
 
   /* Convert the argument to lowercase if appropriate.  */
   if (arg && option->cl_tolower)
diff --git a/gcc/opts-global.c b/gcc/opts-global.c
index bfa2afb1987..b45d18996a3 100644
--- a/gcc/opts-global.c
+++ b/gcc/opts-global.c
@@ -100,10 +100,14 @@ complain_wrong_lang (const struct cl_decoded_option *decoded,
 	   text, bad_lang);
   else if (lang_mask == CL_DRIVER)
 gcc_unreachable ();
-  else
+  else if (ok_langs[0] != '\0')
 /* Eventually this should become a hard error IMO.  */
 warning (0, "command line option %qs is valid for %s but not for %s",
 	 text, ok_langs, bad_lang);
+  else
+/* Happens for -Werror=warning_name.  */
+warning (0, "%<-Werror=%> argument %qs is not valid for %s",
+	 text, bad_lang);
 
   free (ok_langs);
   free (bad_lang);
-- 
2.22.0



Re: GCC 9 backports

2019-07-04 Thread Martin Liška
Hi.

There are 2 more patches that I've just tested.

Martin
>From ae7d66dad2e43e18cf2889803e30e57bc00f88ad Mon Sep 17 00:00:00 2001
From: marxin 
Date: Wed, 3 Jul 2019 08:32:25 +
Subject: [PATCH 2/2] Backport r272993

gcc/ChangeLog:

2019-07-03  Martin Liska  

	PR tree-optimization/90892
	* builtins.c (inline_expand_builtin_string_cmp): Handle '\0'
	in string constants.

gcc/testsuite/ChangeLog:

2019-07-03  Martin Liska  

	PR tree-optimization/90892
	* gcc.dg/pr90892.c: New test.
---
 gcc/builtins.c | 17 ++---
 gcc/testsuite/gcc.dg/pr90892.c | 14 ++
 2 files changed, 28 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr90892.c

diff --git a/gcc/builtins.c b/gcc/builtins.c
index d37d73fc4a0..9bcb310c015 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -7124,8 +7124,19 @@ inline_expand_builtin_string_cmp (tree exp, rtx target)
 return NULL_RTX;
 
   /* For strncmp, if the length is not a const, not qualify.  */
-  if (is_ncmp && !tree_fits_uhwi_p (len3_tree))
-return NULL_RTX;
+  if (is_ncmp)
+{
+  if (!tree_fits_uhwi_p (len3_tree))
+	return NULL_RTX;
+  else
+	len3 = tree_to_uhwi (len3_tree);
+}
+
+  if (src_str1 != NULL)
+len1 = strnlen (src_str1, len1) + 1;
+
+  if (src_str2 != NULL)
+len2 = strnlen (src_str2, len2) + 1;
 
   int const_str_n = 0;
   if (!len1)
@@ -7140,7 +7151,7 @@ inline_expand_builtin_string_cmp (tree exp, rtx target)
   gcc_checking_assert (const_str_n > 0);
   length = (const_str_n == 1) ? len1 : len2;
 
-  if (is_ncmp && (len3 = tree_to_uhwi (len3_tree)) < length)
+  if (is_ncmp && len3 < length)
 length = len3;
 
   /* If the length of the comparision is larger than the threshold,
diff --git a/gcc/testsuite/gcc.dg/pr90892.c b/gcc/testsuite/gcc.dg/pr90892.c
new file mode 100644
index 000..e4b5310807a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr90892.c
@@ -0,0 +1,14 @@
+/* PR tree-optimization/90892 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+const char *a = "A\0b";
+
+int
+main()
+{
+  if (__builtin_strncmp(a, "A\0", 2) != 0)
+__builtin_abort ();
+
+  return 0;
+}
-- 
2.22.0

>From 7a9894e91edfff690db6d9e5935585952a025327 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Wed, 3 Jul 2019 08:31:35 +
Subject: [PATCH 1/2] Backport r272992

gcc/ChangeLog:

2019-07-03  Martin Liska  

	PR middle-end/90899
	* multiple_target.c (create_dispatcher_calls): Add to comdat
	group only if set for ifunc.

gcc/testsuite/ChangeLog:

2019-07-03  Martin Liska  

	PR middle-end/90899
	* gcc.target/i386/pr90899.c: New test.
---
 gcc/multiple_target.c   | 3 ++-
 gcc/testsuite/gcc.target/i386/pr90899.c | 6 ++
 2 files changed, 8 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr90899.c

diff --git a/gcc/multiple_target.c b/gcc/multiple_target.c
index 0a87241b251..e93c60e7adb 100644
--- a/gcc/multiple_target.c
+++ b/gcc/multiple_target.c
@@ -158,7 +158,8 @@ create_dispatcher_calls (struct cgraph_node *node)
 	{
 	  symtab_node *source = ref->referring;
 	  source->create_reference (inode, IPA_REF_ALIAS);
-	  source->add_to_same_comdat_group (inode);
+	  if (inode->get_comdat_group ())
+		source->add_to_same_comdat_group (inode);
 	}
 	  else
 	gcc_unreachable ();
diff --git a/gcc/testsuite/gcc.target/i386/pr90899.c b/gcc/testsuite/gcc.target/i386/pr90899.c
new file mode 100644
index 000..e0e2d5ac6bb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr90899.c
@@ -0,0 +1,6 @@
+/* PR middle-end/90899 */
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+
+__attribute__ ((target_clones ("default", "arch=slm"))) static int f () { return 0; }
+__attribute__ ((alias ("f"))) __typeof (f) g;
-- 
2.22.0



Re: GCC 9 backports

2019-05-24 Thread Martin Liška
Hi.

I'm sending one more patch that I've tested.

Martin
>From 279c24c2af259c8f3e7668056fcb707bc3c03ad2 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Thu, 23 May 2019 10:12:01 +
Subject: [PATCH] Backport r271548

gcc/ChangeLog:

2019-05-23  Martin Liska  

	PR sanitizer/90570
	* gimplify.c (gimplify_target_expr): Skip TREE_STATIC target
	expression similarly to gimplify_decl_expr.

gcc/testsuite/ChangeLog:

2019-05-23  Martin Liska  

	PR sanitizer/90570
	* g++.dg/asan/pr90570.C: New test.
---
 gcc/gimplify.c  |  1 +
 gcc/testsuite/g++.dg/asan/pr90570.C | 18 ++
 2 files changed, 19 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/asan/pr90570.C

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index e59f38261c3..72f1cc38ff7 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -6662,6 +6662,7 @@ gimplify_target_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
 	}
 	  if (asan_poisoned_variables
 	  && DECL_ALIGN (temp) <= MAX_SUPPORTED_STACK_ALIGNMENT
+	  && !TREE_STATIC (temp)
 	  && dbg_cnt (asan_use_after_scope)
 	  && !gimplify_omp_ctxp)
 	{
diff --git a/gcc/testsuite/g++.dg/asan/pr90570.C b/gcc/testsuite/g++.dg/asan/pr90570.C
new file mode 100644
index 000..c2366905516
--- /dev/null
+++ b/gcc/testsuite/g++.dg/asan/pr90570.C
@@ -0,0 +1,18 @@
+/* PR sanitizer/90570 */
+/* { dg-do run } */
+
+#include 
+
+struct stru
+{
+  std::vector v{1,2,3,4};
+  int i{5};
+};
+
+int main()
+{
+  stru s1;
+  stru s2;
+
+  return 0;
+}
-- 
2.21.0



Re: GCC 9 backports

2019-05-14 Thread Martin Liška
On 5/14/19 10:45 AM, Martin Liška wrote:
> Hi.
> 
> There are 2 backport patches that I've just tested and I'm going to install 
> them.
> 
> Martin
> 

One more patch.

Martin
>From fb33e008c2e2a9216cae193d46c08e266250b6ae Mon Sep 17 00:00:00 2001
From: marxin 
Date: Mon, 13 May 2019 10:26:09 +
Subject: [PATCH] Backport r271118

gcc/ChangeLog:

2019-05-13  Martin Liska  

	PR tree-optimization/90416
	* tree-vect-stmts.c (vect_check_load_store_mask): Concatenate
	string instead of passing the second part as va_arg argument.
---
 gcc/tree-vect-stmts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 41a7eb0b9a7..a5fa8ec3a86 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -2568,7 +2568,7 @@ vect_check_load_store_mask (stmt_vec_info stmt_info, tree mask,
 {
   if (dump_enabled_p ())
 	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			 "vector mask type %T",
+			 "vector mask type %T"
 			 " does not match vector data type %T.\n",
 			 mask_vectype, vectype);
 
-- 
2.21.0



GCC 9 backports

2019-05-14 Thread Martin Liška
Hi.

There are 2 backport patches that I've just tested and I'm going to install 
them.

Martin
>From 4ad5f7ebfa965fc65acca851e48e9f56e9a2f20d Mon Sep 17 00:00:00 2001
From: marxin 
Date: Mon, 13 May 2019 07:04:58 +
Subject: [PATCH 1/2] Backport r271116

gcc/ChangeLog:

2019-05-13  Martin Liska  

	PR gcov-profile/90380
	* gcov.c (enum loop_type): Remove the enum and
	the operator.
	(handle_cycle): Assert that we should not reach
	a negative count.
	(circuit): Use loop_found instead of a tri-state loop_type.
	(get_cycles_count): Do not handle NEGATIVE_LOOP as it can't
	happen.
---
 gcc/gcov.c | 53 ++---
 1 file changed, 18 insertions(+), 35 deletions(-)

diff --git a/gcc/gcov.c b/gcc/gcov.c
index 1fc37a07c34..6bcd2b23748 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -676,27 +676,11 @@ bool function_info::group_line_p (unsigned n, unsigned src_idx)
 typedef vector arc_vector_t;
 typedef vector block_vector_t;
 
-/* Enum with types of loop in CFG.  */
-
-enum loop_type
-{
-  NO_LOOP = 0,
-  LOOP = 1,
-  NEGATIVE_LOOP = 3
-};
-
-/* Loop_type operator that merges two values: A and B.  */
-
-inline loop_type& operator |= (loop_type& a, loop_type b)
-{
-return a = static_cast (a | b);
-}
-
 /* Handle cycle identified by EDGES, where the function finds minimum cs_count
and subtract the value from all counts.  The subtracted value is added
to COUNT.  Returns type of loop.  */
 
-static loop_type
+static void
 handle_cycle (const arc_vector_t , int64_t )
 {
   /* Find the minimum edge of the cycle, and reduce all nodes in the cycle by
@@ -712,7 +696,7 @@ handle_cycle (const arc_vector_t , int64_t )
   for (unsigned i = 0; i < edges.size (); i++)
 edges[i]->cs_count -= cycle_count;
 
-  return cycle_count < 0 ? NEGATIVE_LOOP : LOOP;
+  gcc_assert (cycle_count >= 0);
 }
 
 /* Unblock a block U from BLOCKED.  Apart from that, iterate all blocks
@@ -743,12 +727,12 @@ unblock (const block_info *u, block_vector_t ,
blocked by a block.  COUNT is accumulated count of the current LINE.
Returns what type of loop it contains.  */
 
-static loop_type
+static bool
 circuit (block_info *v, arc_vector_t , block_info *start,
 	 block_vector_t , vector _lists,
 	 line_info , int64_t )
 {
-  loop_type result = NO_LOOP;
+  bool loop_found = false;
 
   /* Add v to the block list.  */
   gcc_assert (find (blocked.begin (), blocked.end (), v) == blocked.end ());
@@ -763,15 +747,19 @@ circuit (block_info *v, arc_vector_t , block_info *start,
 
   path.push_back (arc);
   if (w == start)
-	/* Cycle has been found.  */
-	result |= handle_cycle (path, count);
+	{
+	  /* Cycle has been found.  */
+	  handle_cycle (path, count);
+	  loop_found = true;
+	}
   else if (find (blocked.begin (), blocked.end (), w) == blocked.end ())
-	result |= circuit (w, path, start, blocked, block_lists, linfo, count);
+	loop_found |= circuit (w, path, start, blocked, block_lists, linfo,
+			   count);
 
   path.pop_back ();
 }
 
-  if (result != NO_LOOP)
+  if (loop_found)
 unblock (v, blocked, block_lists);
   else
 for (arc_info *arc = v->succ; arc; arc = arc->succ_next)
@@ -788,14 +776,13 @@ circuit (block_info *v, arc_vector_t , block_info *start,
 	  list.push_back (v);
   }
 
-  return result;
+  return loop_found;
 }
 
-/* Find cycles for a LINFO.  If HANDLE_NEGATIVE_CYCLES is set and the line
-   contains a negative loop, then perform the same function once again.  */
+/* Find cycles for a LINFO.  */
 
 static gcov_type
-get_cycles_count (line_info , bool handle_negative_cycles = true)
+get_cycles_count (line_info )
 {
   /* Note that this algorithm works even if blocks aren't in sorted order.
  Each iteration of the circuit detection is completely independent
@@ -803,7 +790,7 @@ get_cycles_count (line_info , bool handle_negative_cycles = true)
  Therefore, operating on a permuted order (i.e., non-sorted) only
  has the effect of permuting the output cycles.  */
 
-  loop_type result = NO_LOOP;
+  bool loop_found = false;
   gcov_type count = 0;
   for (vector::iterator it = linfo.blocks.begin ();
it != linfo.blocks.end (); it++)
@@ -811,14 +798,10 @@ get_cycles_count (line_info , bool handle_negative_cycles = true)
   arc_vector_t path;
   block_vector_t blocked;
   vector block_lists;
-  result |= circuit (*it, path, *it, blocked, block_lists, linfo,
-			 count);
+  loop_found |= circuit (*it, path, *it, blocked, block_lists, linfo,
+			 count);
 }
 
-  /* If we have a negative cycle, repeat the find_cycles routine.  */
-  if (result == NEGATIVE_LOOP && handle_negative_cycles)
-count += get_cycles_count (linfo, false);
-
   return count;
 }
 
-- 
2.21.0

>From b566f10c6650baabc72cf090a08774936b1f703b Mon Sep 17 00:00:00 2001
From: marxin 
Date: Mon, 13 May 2019 07:05:23 +
Subject: [PATCH 2/2] Backport r271117

gcc/ChangeLog:

2019-05-13  Martin Liska  

	PR gcov-profile/90380
	* gcov.c