public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* GCC 8 backports
@ 2018-05-23  8:43 Martin Liška
  2018-08-16 10:14 ` Martin Liška
                   ` (3 more replies)
  0 siblings, 4 replies; 26+ messages in thread
From: Martin Liška @ 2018-05-23  8:43 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 130 bytes --]

Hi.

I'm going to backport following 2 revisions.
Patches can bootstrap on x86_64-linux-gnu and survive regression tests.

Martin

[-- Attachment #2: 0001-patch-260154.patch --]
[-- Type: text/x-patch, Size: 3945 bytes --]

From 3308817aa11be9d43cd564d249dae1c28bf41015 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 11 May 2018 07:37:35 +0000
Subject: Backport r260154

gcc/ChangeLog:

2018-05-11  Martin Liska  <mliska@suse.cz>

        PR sanitizer/85556
	* doc/extend.texi: Document LLVM style format for no_sanitize
	attribute.

gcc/c-family/ChangeLog:

2018-05-11  Martin Liska  <mliska@suse.cz>

        PR sanitizer/85556
	* c-attribs.c (handle_no_sanitize_attribute): Iterate all
	TREE_LIST values.

gcc/testsuite/ChangeLog:

2018-05-11  Martin Liska  <mliska@suse.cz>

        PR sanitizer/85556
	* c-c++-common/ubsan/attrib-6.c: New test.

---
diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index 9bddc1aad4f..d302b4f22c7 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -403,7 +403,7 @@ const struct attribute_spec c_common_attribute_table[] =
 			      0, 0, true, false, false, false,
 			      handle_no_address_safety_analysis_attribute,
 			      NULL },
-  { "no_sanitize",	      1, 1, true, false, false, false,
+  { "no_sanitize",	      1, -1, true, false, false, false,
 			      handle_no_sanitize_attribute, NULL },
   { "no_sanitize_address",    0, 0, true, false, false, false,
 			      handle_no_sanitize_address_attribute, NULL },
@@ -683,22 +683,26 @@ static tree
 handle_no_sanitize_attribute (tree *node, tree name, tree args, int,
 			      bool *no_add_attrs)
 {
+  unsigned int flags = 0;
   *no_add_attrs = true;
-  tree id = TREE_VALUE (args);
   if (TREE_CODE (*node) != FUNCTION_DECL)
     {
       warning (OPT_Wattributes, "%qE attribute ignored", name);
       return NULL_TREE;
     }

-  if (TREE_CODE (id) != STRING_CST)
+  for (; args; args = TREE_CHAIN (args))
     {
-      error ("no_sanitize argument not a string");
-      return NULL_TREE;
-    }
+      tree id = TREE_VALUE (args);
+      if (TREE_CODE (id) != STRING_CST)
+	{
+	  error ("no_sanitize argument not a string");
+	  return NULL_TREE;
+	}

-  char *string = ASTRDUP (TREE_STRING_POINTER (id));
-  unsigned int flags = parse_no_sanitize_attribute (string);
+      char *string = ASTRDUP (TREE_STRING_POINTER (id));
+      flags |= parse_no_sanitize_attribute (string);
+    }

   add_no_sanitize_value (*node, flags);

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 9d085844cfd..a4664cad819 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -2977,6 +2977,8 @@ mentioned in @var{sanitize_option}.  A list of values acceptable by
 @smallexample
 void __attribute__ ((no_sanitize ("alignment", "object-size")))
 f () @{ /* @r{Do something.} */; @}
+void __attribute__ ((no_sanitize ("alignment,object-size")))
+g () @{ /* @r{Do something.} */; @}
 @end smallexample

 @item no_sanitize_address
diff --git a/gcc/testsuite/c-c++-common/ubsan/attrib-6.c b/gcc/testsuite/c-c++-common/ubsan/attrib-6.c
new file mode 100644
index 00000000000..2af70c8c2cf
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/ubsan/attrib-6.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=undefined" } */
+
+static void __attribute__((no_sanitize("foobar")))
+foo (void) { /* { dg-warning "attribute directive ignored" } */
+}
+
+static void __attribute__((no_sanitize("address,undefined")))
+foo2 (void) {
+}
+
+static void __attribute__((no_sanitize("address", "undefined")))
+foo3 (void) {
+}
+
+static void __attribute__((no_sanitize("address", "address", "")))
+foo4 (void) {
+}
+
+static void __attribute__((no_sanitize("address", "address", "address,address")))
+foo5 (void) {
+}
+
+static void __attribute__((no_sanitize("address", "address,kernel-address,thread,leak,undefined,vptr,shift,integer-divide-by-zero,unreachable,vla-bound,null,return,signed-integer-overflow,bounds,bounds-strict,alignment,object-size,float-divide-by-zero,float-cast-overflow,nonnull-attribute,returns-nonnull-attribute,bool,enum")))
+foo6 (void) {
+}
--
2.16.3

[-- Attachment #3: 0002-patch-260566.patch --]
[-- Type: text/x-patch, Size: 2411 bytes --]

From 8203f7efd03cc82717ab0416a151e96d3a7b8f4b Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 23 May 2018 07:40:43 +0000
Subject: Backport r260566

gcc/ChangeLog:

2018-05-23  Yury Gribov  <tetra2005@gmail.com>

	PR tree-optimization/85822
	* tree-vrp.c (is_masked_range_test): Fix handling of negative
	constants.

gcc/testsuite/ChangeLog:

2018-05-23  Yury Gribov  <tetra2005@gmail.com>

	PR tree-optimization/85822
	* c-c++-common/pr85822.c: New test.

---
diff --git a/gcc/testsuite/c-c++-common/pr85822.c b/gcc/testsuite/c-c++-common/pr85822.c
new file mode 100644
index 00000000000..3b09188ab47
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr85822.c
@@ -0,0 +1,27 @@
+/* { dg-options "-O2" } */
+/* { dg-do run } */
+
+static const long long int TagTypeNumber = 0xffff000000000000ll;
+
+long long int x;
+
+void foo(void)
+{
+  x = TagTypeNumber + 1;
+}
+
+int main(int argc, char **argv)
+{
+  if (argc > 0)
+    foo ();
+
+  if ((x & TagTypeNumber) == TagTypeNumber)
+  {
+    unsigned y = (unsigned)x;
+    __builtin_printf ("v: %u\n", y);
+    if (y != 1)
+      __builtin_abort ();
+  }
+
+  return 0;
+}
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index aa53db65576..6c482dd3e46 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -3844,10 +3844,10 @@ register_edge_assert_for_1 (tree op, enum tree_code code,
    Such comparison can yield assertions like
      X >= XX...X00...0
      X <= XX...X11...1
-   in case of COND_OP being NE_EXPR or
+   in case of COND_OP being EQ_EXPR or
      X < XX...X00...0
      X > XX...X11...1
-   in case of EQ_EXPR.  */
+   in case of NE_EXPR.  */

 static bool
 is_masked_range_test (tree name, tree valt, enum tree_code cond_code,
@@ -3867,6 +3867,10 @@ is_masked_range_test (tree name, tree valt, enum tree_code cond_code,

   wi::tree_to_wide_ref mask = wi::to_wide (maskt);
   wide_int inv_mask = ~mask;
+  /* Must have been removed by now so don't bother optimizing.  */
+  if (mask == 0 || inv_mask == 0)
+    return false;
+
   /* Assume VALT is INTEGER_CST.  */
   wi::tree_to_wide_ref val = wi::to_wide (valt);

@@ -3907,9 +3911,6 @@ is_masked_range_test (tree name, tree valt, enum tree_code cond_code,
   *low = wide_int_to_tree (type, val);
   *high = wide_int_to_tree (type, val | inv_mask);

-  if (wi::neg_p (val, TYPE_SIGN (type)))
-    std::swap (*low, *high);
-
   return true;
 }

--
2.16.3

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2018-05-23  8:43 GCC 8 backports Martin Liška
@ 2018-08-16 10:14 ` Martin Liška
  2018-09-18  9:37   ` Martin Liška
  2020-01-15 10:15 ` Martin Liška
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 26+ messages in thread
From: Martin Liška @ 2018-08-16 10:14 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 46 bytes --]

Hi.

Another 2 patches that I tested.

Martin

[-- Attachment #2: 0002-patch-263248.patch --]
[-- Type: text/x-patch, Size: 1762 bytes --]

From 733fad0936b46794f9e1ba6742471bd9f351a4c9 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 2 Aug 2018 10:17:34 +0000
Subject: Backport r263248

gcc/ChangeLog:

2018-08-02  Martin Liska  <mliska@suse.cz>

        PR gcov-profile/86817
	* gcov.c (process_all_functions): New function.
	(main): Call it.
	(process_file): Move functions processing to
        process_all_functions.

---
diff --git a/gcc/gcov.c b/gcc/gcov.c
index 78a3e0e19e9..43dfc9a4b2c 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -543,6 +543,7 @@ static int process_args (int, char **);
 static void print_usage (int) ATTRIBUTE_NORETURN;
 static void print_version (void) ATTRIBUTE_NORETURN;
 static void process_file (const char *);
+static void process_all_functions (void);
 static void generate_results (const char *);
 static void create_file_names (const char *);
 static char *canonicalize_name (const char *);
@@ -798,6 +799,7 @@ main (int argc, char **argv)

       if (flag_intermediate_format || argno == argc - 1)
 	{
+	  process_all_functions ();
 	  generate_results (argv[argno]);
 	  release_structures ();
 	}
@@ -1145,11 +1147,14 @@ process_file (const char *file_name)
 {
   create_file_names (file_name);
   read_graph_file ();
-  if (functions.empty ())
-    return;
-
   read_count_file ();
+}

+/* Process all functions in all files.  */
+
+static void
+process_all_functions (void)
+{
   hash_map<function_start_pair_hash, function_info *> fn_map;

   /* Identify group functions.  */
@@ -1226,7 +1231,6 @@ process_file (const char *file_name)
 	  if (fn->is_group)
 	    fn->lines.resize (fn->end_line - fn->start_line + 1);

-
 	  solve_flow_graph (fn);
 	  if (fn->has_catch)
 	    find_exception_blocks (fn);
--
2.18.0

[-- Attachment #3: 0001-patch-263246.patch --]
[-- Type: text/x-patch, Size: 1086 bytes --]

From 1a1934d31636a8bd72a6d93143dbe216ff6e6ad4 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 2 Aug 2018 09:32:58 +0000
Subject: Backport r263246

libsanitizer/ChangeLog:

2018-08-02  Martin Liska  <mliska@suse.cz>

        PR sanitizer/86022
	* sanitizer_common/sanitizer_linux_libcdep.cc (ThreadDescriptorSize):
        Cherry-pick compiler-rt revision 338606.

---
diff --git a/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc b/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc
index d27a8435802..3b1a2174c46 100644
--- a/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc
@@ -235,7 +235,7 @@ uptr ThreadDescriptorSize() {
         val = FIRST_32_SECOND_64(1168, 1776);
       else if (minor == 11 || (minor == 12 && patch == 1))
         val = FIRST_32_SECOND_64(1168, 2288);
-      else if (minor <= 13)
+      else if (minor <= 14)
         val = FIRST_32_SECOND_64(1168, 2304);
       else
         val = FIRST_32_SECOND_64(1216, 2304);
--
2.18.0

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2018-08-16 10:14 ` Martin Liška
@ 2018-09-18  9:37   ` Martin Liška
  2018-09-25  6:52     ` Martin Liška
  0 siblings, 1 reply; 26+ messages in thread
From: Martin Liška @ 2018-09-18  9:37 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 36 bytes --]

Hi.

One more tested patch.

Martin

[-- Attachment #2: 0001-Backport-r264363.patch --]
[-- Type: text/x-patch, Size: 904 bytes --]

From ee960f3dcad03652cd133b8598131aed488c11cb Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 17 Sep 2018 10:19:02 +0000
Subject: [PATCH] Backport r264363

gcc/ChangeLog:

2018-09-17  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/85871
	* gcov.c (output_intermediate_file): Fix out of bounds
	access.
---
 gcc/gcov.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/gcov.c b/gcc/gcov.c
index 7f06cf66d0c..c7c52ce3629 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -1068,7 +1068,8 @@ output_intermediate_file (FILE *gcov_file, source_info *src)
 	}
 
       /* Follow with lines associated with the source file.  */
-      output_intermediate_line (gcov_file, &src->lines[line_num], line_num);
+      if (line_num < src->lines.size ())
+	output_intermediate_line (gcov_file, &src->lines[line_num], line_num);
     }
 }
 
-- 
2.18.0


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2018-09-18  9:37   ` Martin Liška
@ 2018-09-25  6:52     ` Martin Liška
  2018-10-03 10:09       ` Martin Liška
  0 siblings, 1 reply; 26+ messages in thread
From: Martin Liška @ 2018-09-25  6:52 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 36 bytes --]

Hi.

One more tested patch.

Martin

[-- Attachment #2: 0001-Backport-r264528.patch --]
[-- Type: text/x-patch, Size: 3430 bytes --]

From 62538e940432b55cf38e96e1a2cd72ed1f5f569f Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 24 Sep 2018 11:22:38 +0000
Subject: [PATCH] Backport r264528

gcc/ChangeLog:

2018-09-24  Martin Liska  <mliska@suse.cz>

	PR sanitizer/85774
	* asan.c: Make asan_handled_variables extern.
	* asan.h: Likewise.
	* cfgexpand.c (expand_stack_vars): Make sure
	a representative is unpoison if another
	variable in the partition is handled by
	use-after-scope sanitization.

gcc/testsuite/ChangeLog:

2018-09-24  Martin Liska  <mliska@suse.cz>

	PR sanitizer/85774
	* g++.dg/asan/pr85774.C: New test.
---
 gcc/asan.c                          |  2 +-
 gcc/asan.h                          |  2 ++
 gcc/cfgexpand.c                     | 14 ++++++++
 gcc/testsuite/g++.dg/asan/pr85774.C | 51 +++++++++++++++++++++++++++++
 4 files changed, 68 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/asan/pr85774.C

diff --git a/gcc/asan.c b/gcc/asan.c
index e71ab2cc710..235e219479d 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -253,7 +253,7 @@ static tree last_alloca_addr;
 /* Set of variable declarations that are going to be guarded by
    use-after-scope sanitizer.  */
 
-static hash_set<tree> *asan_handled_variables = NULL;
+hash_set<tree> *asan_handled_variables = NULL;
 
 hash_set <tree> *asan_used_labels = NULL;
 
diff --git a/gcc/asan.h b/gcc/asan.h
index 412af220597..2f431b4f938 100644
--- a/gcc/asan.h
+++ b/gcc/asan.h
@@ -110,6 +110,8 @@ extern bool asan_sanitize_stack_p (void);
 
 extern bool asan_sanitize_allocas_p (void);
 
+extern hash_set<tree> *asan_handled_variables;
+
 /* Return TRUE if builtin with given FCODE will be intercepted by
    libasan.  */
 
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index eca38d5ab6c..13984749985 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -1157,6 +1157,20 @@ expand_stack_vars (bool (*pred) (size_t), struct stack_vars_data *data)
 	      if (repr_decl == NULL_TREE)
 		repr_decl = stack_vars[i].decl;
 	      data->asan_decl_vec.safe_push (repr_decl);
+
+	      /* Make sure a representative is unpoison if another
+		 variable in the partition is handled by
+		 use-after-scope sanitization.  */
+	      if (asan_handled_variables != NULL
+		  && !asan_handled_variables->contains (repr_decl))
+		{
+		  for (j = i; j != EOC; j = stack_vars[j].next)
+		    if (asan_handled_variables->contains (stack_vars[j].decl))
+		      break;
+		  if (j != EOC)
+		    asan_handled_variables->add (repr_decl);
+		}
+
 	      data->asan_alignb = MAX (data->asan_alignb, alignb);
 	      if (data->asan_base == NULL)
 		data->asan_base = gen_reg_rtx (Pmode);
diff --git a/gcc/testsuite/g++.dg/asan/pr85774.C b/gcc/testsuite/g++.dg/asan/pr85774.C
new file mode 100644
index 00000000000..c033abfd69b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/asan/pr85774.C
@@ -0,0 +1,51 @@
+/* PR sanitizer/85774 */
+/* { dg-do run } */
+
+#include <functional>
+
+void
+DoSomething ()
+{
+}
+
+void
+DoFunc (const std::function<void(void)> &func)
+{
+  func ();
+}
+
+void
+Setup ()
+{
+  switch (1)
+    {
+    case 1:
+      {
+	DoFunc ([]() {});
+	break;
+      }
+    case 2:
+      {
+	DoFunc ([]() {});
+	break;
+      }
+    default:
+      break;
+    }
+
+  DoSomething ();
+}
+
+void
+DemostrateBadPoisoning ()
+{
+  DoFunc ([]() {});
+}
+
+int
+main ()
+{
+  Setup ();
+  DemostrateBadPoisoning ();
+  return 0;
+}
-- 
2.19.0


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2018-09-25  6:52     ` Martin Liška
@ 2018-10-03 10:09       ` Martin Liška
  2018-11-20 10:58         ` Martin Liška
  0 siblings, 1 reply; 26+ messages in thread
From: Martin Liška @ 2018-10-03 10:09 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 124 bytes --]

On 9/25/18 8:48 AM, Martin Liška wrote:
> Hi.
> 
> One more tested patch.
> 
> Martin
> 

One more tested patch.

Martin

[-- Attachment #2: 0001-Backport-r264806.patch --]
[-- Type: text/x-patch, Size: 3931 bytes --]

From d5ac07522f558372f13e95ea05593adae36e5dfa Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Wed, 3 Oct 2018 10:39:16 +0200
Subject: [PATCH] Backport r264806

gcc/ChangeLog:

2018-10-03  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/86109
	* coverage.c (coverage_begin_function): Do not
	mark lambdas as artificial.
	* tree-core.h (struct GTY): Remove tm_clone_flag
	and introduce new lambda_function.
	* tree.h (DECL_LAMBDA_FUNCTION): New macro.

gcc/cp/ChangeLog:

2018-10-03  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/86109
	* parser.c (cp_parser_lambda_declarator_opt):
	Set DECL_LAMBDA_FUNCTION for lambdas.

gcc/testsuite/ChangeLog:

2018-10-03  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/86109
	* g++.dg/gcov/pr86109.C: New test.
---
 gcc/coverage.c                      |  3 ++-
 gcc/cp/parser.c                     |  1 +
 gcc/testsuite/g++.dg/gcov/pr86109.C | 16 ++++++++++++++++
 gcc/tree-core.h                     |  2 +-
 gcc/tree.h                          |  4 ++++
 5 files changed, 24 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/gcov/pr86109.C

diff --git a/gcc/coverage.c b/gcc/coverage.c
index 32ef298a11f..bae3d507638 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -663,7 +663,8 @@ coverage_begin_function (unsigned lineno_checksum, unsigned cfg_checksum)
   gcov_write_unsigned (cfg_checksum);
   gcov_write_string (IDENTIFIER_POINTER
 		     (DECL_ASSEMBLER_NAME (current_function_decl)));
-  gcov_write_unsigned (DECL_ARTIFICIAL (current_function_decl));
+  gcov_write_unsigned (DECL_ARTIFICIAL (current_function_decl)
+		       && !DECL_LAMBDA_FUNCTION (current_function_decl));
   gcov_write_filename (xloc.file);
   gcov_write_unsigned (xloc.line);
   gcov_write_unsigned (xloc.column);
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index bbf1a71d415..b40bee6d33b 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -10620,6 +10620,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
 	DECL_ARTIFICIAL (fco) = 1;
 	/* Give the object parameter a different name.  */
 	DECL_NAME (DECL_ARGUMENTS (fco)) = get_identifier ("__closure");
+	DECL_LAMBDA_FUNCTION (fco) = 1;
 	if (return_type)
 	  TYPE_HAS_LATE_RETURN_TYPE (TREE_TYPE (fco)) = 1;
       }
diff --git a/gcc/testsuite/g++.dg/gcov/pr86109.C b/gcc/testsuite/g++.dg/gcov/pr86109.C
new file mode 100644
index 00000000000..9052d2e5a04
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gcov/pr86109.C
@@ -0,0 +1,16 @@
+
+/* { dg-options "-fprofile-arcs -ftest-coverage -std=c++11" } */
+/* { dg-do run { target native } } */
+
+int main()
+{
+    auto partially_uncovered_lambda = [](int i) { /* count(1) */
+        if (i > 10) /* count(1) */
+            return 0; /* count(1) */
+        return 1; /* count(#####) */
+    };
+
+    return partially_uncovered_lambda(20); /* count(1) */
+}
+
+/* { dg-final { run-gcov pr86109.C } } */
diff --git a/gcc/tree-core.h b/gcc/tree-core.h
index 478c631998c..356330a5b0e 100644
--- a/gcc/tree-core.h
+++ b/gcc/tree-core.h
@@ -1796,8 +1796,8 @@ struct GTY(()) tree_function_decl {
   unsigned pure_flag : 1;
   unsigned looping_const_or_pure_flag : 1;
   unsigned has_debug_args_flag : 1;
-  unsigned tm_clone_flag : 1;
   unsigned versioned_function : 1;
+  unsigned lambda_function: 1;
   /* No bits left.  */
 };
 
diff --git a/gcc/tree.h b/gcc/tree.h
index 1e14d9f5866..8e703140811 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -3061,6 +3061,10 @@ extern vec<tree, va_gc> **decl_debug_args_insert (tree);
 #define DECL_CXX_DESTRUCTOR_P(NODE)\
    (FUNCTION_DECL_CHECK (NODE)->decl_with_vis.cxx_destructor)
 
+/* In FUNCTION_DECL, this is set if this function is a lambda function.  */
+#define DECL_LAMBDA_FUNCTION(NODE) \
+  (FUNCTION_DECL_CHECK (NODE)->function_decl.lambda_function)
+
 /* In FUNCTION_DECL that represent an virtual method this is set when
    the method is final.  */
 #define DECL_FINAL_P(NODE)\
-- 
2.19.0


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2018-10-03 10:09       ` Martin Liška
@ 2018-11-20 10:58         ` Martin Liška
  2018-12-27 14:59           ` Martin Liška
  2019-02-14 11:23           ` Martin Liška
  0 siblings, 2 replies; 26+ messages in thread
From: Martin Liška @ 2018-11-20 10:58 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 250 bytes --]

On 10/3/18 11:23 AM, Martin Liška wrote:
> On 9/25/18 8:48 AM, Martin Liška wrote:
>> Hi.
>>
>> One more tested patch.
>>
>> Martin
>>
> 
> One more tested patch.
> 
> Martin
> 

Hi.

One another tested patch that I'm going to install.

Martin

[-- Attachment #2: 0001-Backport-r266277.patch --]
[-- Type: text/x-patch, Size: 1949 bytes --]

From 94cd1e55e5baec63b7a80c59fdd8b5c52595c9e9 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 19 Nov 2018 15:00:41 +0000
Subject: [PATCH] Backport r266277

gcc/lto/ChangeLog:

2018-11-19  Martin Liska  <mliska@suse.cz>

	PR lto/88077
	* lto-symtab.c (lto_symtab_merge): Transform the
	condition before r256989.

gcc/testsuite/ChangeLog:

2018-11-19  Martin Liska  <mliska@suse.cz>

	PR lto/88077
	* gcc.dg/lto/pr88077_0.c: New test.
	* gcc.dg/lto/pr88077_1.c: New test.
---
 gcc/lto/lto-symtab.c                 | 5 +++--
 gcc/testsuite/gcc.dg/lto/pr88077_0.c | 3 +++
 gcc/testsuite/gcc.dg/lto/pr88077_1.c | 6 ++++++
 3 files changed, 12 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/lto/pr88077_0.c
 create mode 100644 gcc/testsuite/gcc.dg/lto/pr88077_1.c

diff --git a/gcc/lto/lto-symtab.c b/gcc/lto/lto-symtab.c
index 3663ab7a9b2..cec74894c02 100644
--- a/gcc/lto/lto-symtab.c
+++ b/gcc/lto/lto-symtab.c
@@ -388,8 +388,9 @@ lto_symtab_merge (symtab_node *prevailing, symtab_node *entry)
 	 int a[]={1,2,3};
 	 here the first declaration is COMMON
 	 and sizeof(a) == sizeof (int).  */
-	else if (TREE_CODE (type) == ARRAY_TYPE)
-	  return (TYPE_SIZE (decl) == TYPE_SIZE (TREE_TYPE (type)));
+	else if (TREE_CODE (type) != ARRAY_TYPE
+		 || (TYPE_SIZE (type) != TYPE_SIZE (TREE_TYPE (type))))
+	  return false;
       }
 
   return true;
diff --git a/gcc/testsuite/gcc.dg/lto/pr88077_0.c b/gcc/testsuite/gcc.dg/lto/pr88077_0.c
new file mode 100644
index 00000000000..9e464b6ad4a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr88077_0.c
@@ -0,0 +1,3 @@
+/* { dg-lto-do link } */
+
+int HeaderStr;
diff --git a/gcc/testsuite/gcc.dg/lto/pr88077_1.c b/gcc/testsuite/gcc.dg/lto/pr88077_1.c
new file mode 100644
index 00000000000..fd3de3e77a6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr88077_1.c
@@ -0,0 +1,6 @@
+char HeaderStr[1];
+
+int main()
+{
+  return 0;
+}
-- 
2.19.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2018-11-20 10:58         ` Martin Liška
@ 2018-12-27 14:59           ` Martin Liška
  2018-12-28 11:46             ` Sudakshina Das
  2019-02-14 11:23           ` Martin Liška
  1 sibling, 1 reply; 26+ messages in thread
From: Martin Liška @ 2018-12-27 14:59 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 395 bytes --]

On 11/20/18 11:58 AM, Martin Liška wrote:
> On 10/3/18 11:23 AM, Martin Liška wrote:
>> On 9/25/18 8:48 AM, Martin Liška wrote:
>>> Hi.
>>>
>>> One more tested patch.
>>>
>>> Martin
>>>
>>
>> One more tested patch.
>>
>> Martin
>>
> 
> Hi.
> 
> One another tested patch that I'm going to install.
> 
> Martin
> 

Hi.

One another tested patch that I'm going to install.

Thanks,
Martin

[-- Attachment #2: 0001-Backport-r267338.patch --]
[-- Type: text/x-patch, Size: 8721 bytes --]

From 97052eab40506300510336bf668d4adc2a60a7cf Mon Sep 17 00:00:00 2001
From: hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 21 Dec 2018 19:13:06 +0000
Subject: [PATCH] Backport r267338

gcc/ChangeLog:

2018-12-15  Jan Hubicka  <hubicka@ucw.cz>

	PR ipa/88561
	* ipa-polymorphic-call.c
	(ipa_polymorphic_call_context::ipa_polymorphic_call_context): Handle
	arguments of thunks correctly.
	(ipa_polymorphic_call_context::get_dynamic_context): Be ready for
	NULL instance pinter.
	* lto-cgraph.c (lto_output_node): Always stream thunk info.

gcc/testsuite/ChangeLog:

2018-12-15  Jan Hubicka  <hubicka@ucw.cz>

	PR ipa/88561
	* g++.dg/tree-prof/devirt.C: New testcase.
---
 gcc/ipa-polymorphic-call.c              |  32 +++++-
 gcc/lto-cgraph.c                        |   8 +-
 gcc/testsuite/g++.dg/tree-prof/devirt.C | 123 ++++++++++++++++++++++++
 3 files changed, 159 insertions(+), 4 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/tree-prof/devirt.C

diff --git a/gcc/ipa-polymorphic-call.c b/gcc/ipa-polymorphic-call.c
index 13aca94dd00..d5e4a6a6f97 100644
--- a/gcc/ipa-polymorphic-call.c
+++ b/gcc/ipa-polymorphic-call.c
@@ -995,9 +995,22 @@ ipa_polymorphic_call_context::ipa_polymorphic_call_context (tree fndecl,
 	{
 	  outer_type
 	     = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (base_pointer)));
+	  cgraph_node *node = cgraph_node::get (current_function_decl);
 	  gcc_assert (TREE_CODE (outer_type) == RECORD_TYPE
 		      || TREE_CODE (outer_type) == UNION_TYPE);
 
+	  /* Handle the case we inlined into a thunk.  In this case
+	     thunk has THIS pointer of type bar, but it really receives
+	     address to its base type foo which sits in bar at
+	     0-thunk.fixed_offset.  It starts with code that adds
+	     think.fixed_offset to the pointer to compensate for this.
+
+	     Because we walked all the way to the begining of thunk, we now
+	     see pointer &bar-thunk.fixed_offset and need to compensate
+	     for it.  */
+	  if (node->thunk.fixed_offset)
+	    offset -= node->thunk.fixed_offset * BITS_PER_UNIT;
+
 	  /* Dynamic casting has possibly upcasted the type
 	     in the hiearchy.  In this case outer type is less
 	     informative than inner type and we should forget
@@ -1005,7 +1018,11 @@ ipa_polymorphic_call_context::ipa_polymorphic_call_context (tree fndecl,
 	  if ((otr_type
 	       && !contains_type_p (outer_type, offset,
 				    otr_type))
-	      || !contains_polymorphic_type_p (outer_type))
+	      || !contains_polymorphic_type_p (outer_type)
+	      /* If we compile thunk with virtual offset, the THIS pointer
+		 is adjusted by unknown value.  We can't thus use outer info
+		 at all.  */
+	      || node->thunk.virtual_offset_p)
 	    {
 	      outer_type = NULL;
 	      if (instance)
@@ -1030,7 +1047,15 @@ ipa_polymorphic_call_context::ipa_polymorphic_call_context (tree fndecl,
 	      maybe_in_construction = false;
 	    }
 	  if (instance)
-	    *instance = base_pointer;
+	    {
+	      /* If method is expanded thunk, we need to apply thunk offset
+		 to instance pointer.  */
+	      if (node->thunk.virtual_offset_p
+		  || node->thunk.fixed_offset)
+		*instance = NULL;
+	      else
+	        *instance = base_pointer;
+	    }
 	  return;
 	}
       /* Non-PODs passed by value are really passed by invisible
@@ -1547,6 +1572,9 @@ ipa_polymorphic_call_context::get_dynamic_type (tree instance,
   HOST_WIDE_INT instance_offset = offset;
   tree instance_outer_type = outer_type;
 
+  if (!instance)
+    return false;
+
   if (otr_type)
     otr_type = TYPE_MAIN_VARIANT (otr_type);
 
diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
index 40baf858ca5..305f22bd7e9 100644
--- a/gcc/lto-cgraph.c
+++ b/gcc/lto-cgraph.c
@@ -546,7 +546,11 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node,
   streamer_write_bitpack (&bp);
   streamer_write_data_stream (ob->main_stream, section, strlen (section) + 1);
 
-  if (node->thunk.thunk_p)
+  /* Stream thunk info always because we use it in
+     ipa_polymorphic_call_context::ipa_polymorphic_call_context
+     to properly interpret THIS pointers for thunks that has been converted
+     to Gimple.  */
+  if (node->definition)
     {
       streamer_write_uhwi_stream
 	 (ob->main_stream,
@@ -1317,7 +1321,7 @@ input_node (struct lto_file_decl_data *file_data,
   if (section)
     node->set_section_for_node (section);
 
-  if (node->thunk.thunk_p)
+  if (node->definition)
     {
       int type = streamer_read_uhwi (ib);
       HOST_WIDE_INT fixed_offset = streamer_read_uhwi (ib);
diff --git a/gcc/testsuite/g++.dg/tree-prof/devirt.C b/gcc/testsuite/g++.dg/tree-prof/devirt.C
new file mode 100644
index 00000000000..05c9a26e7a4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-prof/devirt.C
@@ -0,0 +1,123 @@
+/* { dg-options "-O3 -fdump-tree-dom3" } */
+struct nsISupports
+{
+  virtual int QueryInterface (const int &aIID, void **aInstancePtr) = 0;
+  virtual __attribute__((noinline, noclone)) unsigned AddRef (void) = 0;
+  virtual unsigned Release (void) = 0;
+};
+
+struct nsIObserver : public nsISupports
+{
+  virtual int Observe (nsISupports * aSubject, const char *aTopic, const unsigned short *aData) = 0;
+};
+
+struct nsISupportsWeakReference : public nsISupports
+{
+  virtual int GetWeakReference (void **_retval) = 0;
+};
+
+struct nsSupportsWeakReference : public nsISupportsWeakReference
+{
+  nsSupportsWeakReference () : mProxy (0) {}
+  virtual int GetWeakReference (void **_retval) override { return 0; }
+  ~nsSupportsWeakReference () {}
+  void NoticeProxyDestruction () { mProxy = nullptr; }
+  void *mProxy;
+  void ClearWeakReferences ();
+  bool HasWeakReferences () const { return !!mProxy; }
+};
+
+struct mozIPersonalDictionary : public nsISupports
+{
+  virtual int Load (void) = 0;
+  virtual int Save (void) = 0;
+  virtual int GetWordList (void **aWordList) = 0;
+  virtual int Check (const int &word, bool * _retval) = 0;
+  virtual int AddWord (const int &word) = 0;
+  virtual int RemoveWord (const int &word) = 0;
+  virtual int IgnoreWord (const int &word) = 0;
+  virtual int EndSession (void) = 0;
+};
+
+struct mozPersonalDictionary final
+  : public mozIPersonalDictionary, public nsIObserver, public nsSupportsWeakReference
+{
+  virtual int QueryInterface (const int &aIID, void **aInstancePtr) override;
+  virtual __attribute__((noinline, noclone)) unsigned AddRef (void) override;
+  virtual unsigned Release (void) override;
+  unsigned long mRefCnt;
+  virtual int Load (void) override { return 0; }
+  virtual int Save (void) override { return 0; }
+  virtual int GetWordList (void **aWordList) override { return 0; }
+  virtual int Check (const int &word, bool * _retval) override { return 0; }
+  virtual int AddWord (const int &word) override { return 0; }
+  virtual int RemoveWord (const int &word) override { return 0; }
+  virtual int IgnoreWord (const int &word) override { return 0; }
+  virtual int EndSession (void) override { return 0; }
+  virtual int Observe (nsISupports * aSubject, const char *aTopic, const unsigned short *aData) override { return 0; }
+  mozPersonalDictionary () : mRefCnt(0) {}
+  int Init () { return 0; }
+  virtual ~mozPersonalDictionary () {}
+  bool mIsLoaded;
+  bool mSavePending;
+  void *mFile;
+  char mMonitor[96];
+  char mMonitorSave[96];
+  char mDictionaryTable[32];
+  char mIgnoreTable[32];
+};
+
+unsigned
+mozPersonalDictionary::AddRef (void)
+{
+  unsigned count = ++mRefCnt;
+  return count;
+}
+
+unsigned
+mozPersonalDictionary::Release (void)
+{
+  unsigned count = --mRefCnt;
+  if (count == 0)
+    {
+      mRefCnt = 1;
+      delete (this);
+      return 0;
+    }
+  return count;
+}
+
+int
+mozPersonalDictionary::QueryInterface (const int &aIID, void **aInstancePtr)
+{
+  nsISupports *foundInterface;
+  if (aIID == 122)
+    foundInterface = static_cast <mozIPersonalDictionary *>(this);
+  else
+    foundInterface = static_cast <nsISupportsWeakReference *>(this);
+  int status;
+  foundInterface->AddRef ();
+  *aInstancePtr = foundInterface;
+  return status;
+}
+
+__attribute__((noipa)) int
+foo (nsISupports *p, const int &i)
+{
+  void *q;
+  return p->QueryInterface (i, &q);
+}
+
+int
+main ()
+{
+  mozPersonalDictionary m;
+  int j = 123;
+  for (int i = 0; i < 100000; i++)
+    foo (static_cast <nsISupportsWeakReference *>(&m), j);
+  if (m.mRefCnt != 100000)
+    __builtin_abort ();
+}
+
+/* { dg-final-use-not-autofdo { scan-ipa-dump-times 3 "folding virtual function call to virtual unsigned int mozPersonalDictionary::_ZThn16" "dom3" } } */
+/* { dg-final-use-not-autofdo { scan-ipa-dump-times 3 "folding virtual function call to virtual unsigned int mozPersonalDictionary::AddRef" "dom3" } } */
-- 
2.20.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2018-12-27 14:59           ` Martin Liška
@ 2018-12-28 11:46             ` Sudakshina Das
  2019-01-02 11:46               ` Martin Liška
  0 siblings, 1 reply; 26+ messages in thread
From: Sudakshina Das @ 2018-12-28 11:46 UTC (permalink / raw)
  To: Martin Liška, GCC Patches; +Cc: nd

Hi Martin

On 27/12/18 12:32 PM, Martin Liška wrote:
> On 11/20/18 11:58 AM, Martin Liška wrote:
>> On 10/3/18 11:23 AM, Martin Liška wrote:
>>> On 9/25/18 8:48 AM, Martin Liška wrote:
>>>> Hi.
>>>>
>>>> One more tested patch.
>>>>
>>>> Martin
>>>>
>>> One more tested patch.
>>>
>>> Martin
>>>
>> Hi.
>>
>> One another tested patch that I'm going to install.
>>
>> Martin
>>
> Hi.
>
> One another tested patch that I'm going to install.
>
> Thanks,
> Martin

The last backport of r267338 causes the following failures on 
arm-none-linux-gnueabihf and aarch64-none-linux-gnu

UNRESOLVED: g++.dg/tree-prof/devirt.C scan-ipa-dump-times dom3 "3" 
folding virtual function call to virtual unsigned int 
mozPersonalDictionary::AddRef
UNRESOLVED: g++.dg/tree-prof/devirt.C scan-ipa-dump-times dom3 "3" 
folding virtual function call to virtual unsigned int 
mozPersonalDictionary::_ZThn16

with

g++.dg/tree-prof/devirt.C: dump file does not exist

Thanks

Sudi


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2018-12-28 11:46             ` Sudakshina Das
@ 2019-01-02 11:46               ` Martin Liška
  2019-01-02 11:50                 ` Jan Hubicka
  0 siblings, 1 reply; 26+ messages in thread
From: Martin Liška @ 2019-01-02 11:46 UTC (permalink / raw)
  To: Sudakshina Das, GCC Patches; +Cc: nd, Jan Hubicka

On 12/28/18 12:24 PM, Sudakshina Das wrote:
> Hi Martin
> 
> On 27/12/18 12:32 PM, Martin Liška wrote:
>> On 11/20/18 11:58 AM, Martin Liška wrote:
>>> On 10/3/18 11:23 AM, Martin Liška wrote:
>>>> On 9/25/18 8:48 AM, Martin Liška wrote:
>>>>> Hi.
>>>>>
>>>>> One more tested patch.
>>>>>
>>>>> Martin
>>>>>
>>>> One more tested patch.
>>>>
>>>> Martin
>>>>
>>> Hi.
>>>
>>> One another tested patch that I'm going to install.
>>>
>>> Martin
>>>
>> Hi.
>>
>> One another tested patch that I'm going to install.
>>
>> Thanks,
>> Martin
> 
> The last backport of r267338 causes the following failures on 
> arm-none-linux-gnueabihf and aarch64-none-linux-gnu
> 
> UNRESOLVED: g++.dg/tree-prof/devirt.C scan-ipa-dump-times dom3 "3" 
> folding virtual function call to virtual unsigned int 
> mozPersonalDictionary::AddRef
> UNRESOLVED: g++.dg/tree-prof/devirt.C scan-ipa-dump-times dom3 "3" 
> folding virtual function call to virtual unsigned int 
> mozPersonalDictionary::_ZThn16
> 
> with
> 
> g++.dg/tree-prof/devirt.C: dump file does not exist
> 
> Thanks
> 
> Sudi
> 

Honza, in order to make the test working I would need to backport
r267495. Is it a good idea?

Thanks,
Martin

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2019-01-02 11:46               ` Martin Liška
@ 2019-01-02 11:50                 ` Jan Hubicka
  2019-01-03  8:46                   ` Martin Liška
  0 siblings, 1 reply; 26+ messages in thread
From: Jan Hubicka @ 2019-01-02 11:50 UTC (permalink / raw)
  To: Martin Liška; +Cc: Sudakshina Das, GCC Patches, nd

> 
> Honza, in order to make the test working I would need to backport
> r267495. Is it a good idea?

Yes, my apologies for the mistake! I should stop looking for failures
via grep and use test_summary consistently since I tend to miss
unresolved tests.  Old habits are hard to change.

Honza
> 
> Thanks,
> Martin

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2019-01-02 11:50                 ` Jan Hubicka
@ 2019-01-03  8:46                   ` Martin Liška
  0 siblings, 0 replies; 26+ messages in thread
From: Martin Liška @ 2019-01-03  8:46 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: Sudakshina Das, GCC Patches, nd

[-- Attachment #1: Type: text/plain, Size: 522 bytes --]

On 1/2/19 12:50 PM, Jan Hubicka wrote:
>>
>> Honza, in order to make the test working I would need to backport
>> r267495. Is it a good idea?
> 
> Yes, my apologies for the mistake! I should stop looking for failures
> via grep and use test_summary consistently since I tend to miss
> unresolved tests.  Old habits are hard to change.
> 
> Honza
>>
>> Thanks,
>> Martin

Hi.

So there's a backport of 3 patches that fix the test-case.
Tested and bootstrapped on x86_64-linux-gnu, I'm going
to install the patches.

Martin

[-- Attachment #2: 0003-Backport-r267507.patch --]
[-- Type: text/x-patch, Size: 1665 bytes --]

From 5fd0285a53b7caee98625472adc44cb101bd4873 Mon Sep 17 00:00:00 2001
From: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 2 Jan 2019 09:25:59 +0000
Subject: [PATCH 3/3] Backport r267507

gcc/testsuite/ChangeLog:

2019-01-02  Jakub Jelinek  <jakub@redhat.com>

	PR ipa/88561
	* g++.dg/tree-prof/devirt.C: Expect _ZThn16 only for lp64 and llp64
	targets and expect _ZThn8 for ilp32 targets.
---
 gcc/testsuite/g++.dg/tree-prof/devirt.C | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/g++.dg/tree-prof/devirt.C b/gcc/testsuite/g++.dg/tree-prof/devirt.C
index 7d6797dd226..3de5dbcf688 100644
--- a/gcc/testsuite/g++.dg/tree-prof/devirt.C
+++ b/gcc/testsuite/g++.dg/tree-prof/devirt.C
@@ -1,4 +1,6 @@
+/* PR ipa/88561 */
 /* { dg-options "-O3 -fdump-tree-dom3-details" } */
+
 struct nsISupports
 {
   virtual int QueryInterface (const int &aIID, void **aInstancePtr) = 0;
@@ -119,5 +121,6 @@ main ()
     __builtin_abort ();
 }
 
-/* { dg-final-use-not-autofdo { scan-tree-dump-times "folding virtual function call to virtual unsigned int mozPersonalDictionary::_ZThn16" 1 "dom3" } } */
+/* { dg-final-use-not-autofdo { scan-tree-dump-times "folding virtual function call to virtual unsigned int mozPersonalDictionary::_ZThn16" 1 "dom3" { target { lp64 || llp64 } } } } */
+/* { dg-final-use-not-autofdo { scan-tree-dump-times "folding virtual function call to virtual unsigned int mozPersonalDictionary::_ZThn8" 1 "dom3" { target ilp32 } } } */
 /* { dg-final-use-not-autofdo { scan-tree-dump-times "folding virtual function call to virtual unsigned int mozPersonalDictionary::AddRef" 1 "dom3" } } */
-- 
2.20.1


[-- Attachment #3: 0002-Backport-r267495.patch --]
[-- Type: text/x-patch, Size: 15821 bytes --]

From f3a455cffaee5ac5af2ac188e08c51f3a662491a Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Wed, 2 Jan 2019 12:54:23 +0100
Subject: [PATCH 2/3] Backport r267495

gcc/ChangeLog:

2019-01-01  Jan Hubicka  <hubicka@ucw.cz>

	* coverage.c (get_coverage_counts): Use current_function_decl.
	* profile.c (read_thunk_profile): New function.
	(branch_prob): Add THUNK parameter.
	* tree-profile.c (tree_profiling): Handle thunks.
	* value-prof.c (init_node_map): Handle thunks.
	* value-prof.h (branch_prob): Upate prototype.
	(read_thunk_profile): Declare.

gcc/testsuite/ChangeLog:

2019-01-01  Jan Hubicka  <hubicka@ucw.cz>

	* g++.dg/tree-prof/devirt.C: Update testcase.
---
 gcc/coverage.c                          |   2 +-
 gcc/profile.c                           | 250 ++++++++++++++----------
 gcc/testsuite/g++.dg/tree-prof/devirt.C |   4 +-
 gcc/tree-profile.c                      |  28 ++-
 gcc/value-prof.c                        |   2 +-
 gcc/value-prof.h                        |   3 +-
 6 files changed, 177 insertions(+), 112 deletions(-)

diff --git a/gcc/coverage.c b/gcc/coverage.c
index 75628b1748f..592d3dcef84 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -368,7 +368,7 @@ get_coverage_counts (unsigned counter, unsigned expected,
   else
     {
       gcc_assert (coverage_node_map_initialized_p ());
-      elt.ident = cgraph_node::get (cfun->decl)->profile_id;
+      elt.ident = cgraph_node::get (current_function_decl)->profile_id;
     }
   elt.ctr = counter;
   entry = counts_hash->find (&elt);
diff --git a/gcc/profile.c b/gcc/profile.c
index 6fde0fd29d1..eb9f7d52668 100644
--- a/gcc/profile.c
+++ b/gcc/profile.c
@@ -977,6 +977,25 @@ compare_freqs (const void *p1, const void *p2)
   return e2->dest->index - e1->dest->index;
 }
 
+/* Only read execution count for thunks.  */
+
+void
+read_thunk_profile (struct cgraph_node *node)
+{
+  tree old = current_function_decl;
+  current_function_decl = node->decl;
+  gcov_type *counts = get_coverage_counts (GCOV_COUNTER_ARCS, 1, 0, 0, NULL);
+  if (counts)
+    {
+      node->callees->count = node->count
+	 = profile_count::from_gcov_type (counts[0]);
+      free (counts);
+    }
+  current_function_decl = old;
+  return;
+}
+
+
 /* Instrument and/or analyze program behavior based on program the CFG.
 
    This function creates a representation of the control flow graph (of
@@ -997,7 +1016,7 @@ compare_freqs (const void *p1, const void *p2)
    Main entry point of this file.  */
 
 void
-branch_prob (void)
+branch_prob (bool thunk)
 {
   basic_block bb;
   unsigned i;
@@ -1012,118 +1031,121 @@ branch_prob (void)
   flow_call_edges_add (NULL);
   add_noreturn_fake_exit_edges ();
 
-  /* We can't handle cyclic regions constructed using abnormal edges.
-     To avoid these we replace every source of abnormal edge by a fake
-     edge from entry node and every destination by fake edge to exit.
-     This keeps graph acyclic and our calculation exact for all normal
-     edges except for exit and entrance ones.
-
-     We also add fake exit edges for each call and asm statement in the
-     basic, since it may not return.  */
-
-  FOR_EACH_BB_FN (bb, cfun)
+  if (!thunk)
     {
-      int need_exit_edge = 0, need_entry_edge = 0;
-      int have_exit_edge = 0, have_entry_edge = 0;
-      edge e;
-      edge_iterator ei;
+      /* We can't handle cyclic regions constructed using abnormal edges.
+	 To avoid these we replace every source of abnormal edge by a fake
+	 edge from entry node and every destination by fake edge to exit.
+	 This keeps graph acyclic and our calculation exact for all normal
+	 edges except for exit and entrance ones.
 
-      /* Functions returning multiple times are not handled by extra edges.
-         Instead we simply allow negative counts on edges from exit to the
-         block past call and corresponding probabilities.  We can't go
-         with the extra edges because that would result in flowgraph that
-	 needs to have fake edges outside the spanning tree.  */
+	 We also add fake exit edges for each call and asm statement in the
+	 basic, since it may not return.  */
 
-      FOR_EACH_EDGE (e, ei, bb->succs)
+      FOR_EACH_BB_FN (bb, cfun)
 	{
-	  gimple_stmt_iterator gsi;
-	  gimple *last = NULL;
-
-	  /* It may happen that there are compiler generated statements
-	     without a locus at all.  Go through the basic block from the
-	     last to the first statement looking for a locus.  */
-	  for (gsi = gsi_last_nondebug_bb (bb);
-	       !gsi_end_p (gsi);
-	       gsi_prev_nondebug (&gsi))
+	  int need_exit_edge = 0, need_entry_edge = 0;
+	  int have_exit_edge = 0, have_entry_edge = 0;
+	  edge e;
+	  edge_iterator ei;
+
+	  /* Functions returning multiple times are not handled by extra edges.
+	     Instead we simply allow negative counts on edges from exit to the
+	     block past call and corresponding probabilities.  We can't go
+	     with the extra edges because that would result in flowgraph that
+	     needs to have fake edges outside the spanning tree.  */
+
+	  FOR_EACH_EDGE (e, ei, bb->succs)
 	    {
-	      last = gsi_stmt (gsi);
-	      if (!RESERVED_LOCATION_P (gimple_location (last)))
-		break;
-	    }
+	      gimple_stmt_iterator gsi;
+	      gimple *last = NULL;
+
+	      /* It may happen that there are compiler generated statements
+		 without a locus at all.  Go through the basic block from the
+		 last to the first statement looking for a locus.  */
+	      for (gsi = gsi_last_nondebug_bb (bb);
+		   !gsi_end_p (gsi);
+		   gsi_prev_nondebug (&gsi))
+		{
+		  last = gsi_stmt (gsi);
+		  if (!RESERVED_LOCATION_P (gimple_location (last)))
+		    break;
+		}
 
-	  /* Edge with goto locus might get wrong coverage info unless
-	     it is the only edge out of BB.
-	     Don't do that when the locuses match, so
-	     if (blah) goto something;
-	     is not computed twice.  */
-	  if (last
-	      && gimple_has_location (last)
-	      && !RESERVED_LOCATION_P (e->goto_locus)
-	      && !single_succ_p (bb)
-	      && (LOCATION_FILE (e->goto_locus)
-	          != LOCATION_FILE (gimple_location (last))
-		  || (LOCATION_LINE (e->goto_locus)
-		      != LOCATION_LINE (gimple_location (last)))))
+	      /* Edge with goto locus might get wrong coverage info unless
+		 it is the only edge out of BB.
+		 Don't do that when the locuses match, so
+		 if (blah) goto something;
+		 is not computed twice.  */
+	      if (last
+		  && gimple_has_location (last)
+		  && !RESERVED_LOCATION_P (e->goto_locus)
+		  && !single_succ_p (bb)
+		  && (LOCATION_FILE (e->goto_locus)
+		      != LOCATION_FILE (gimple_location (last))
+		      || (LOCATION_LINE (e->goto_locus)
+			  != LOCATION_LINE (gimple_location (last)))))
+		{
+		  basic_block new_bb = split_edge (e);
+		  edge ne = single_succ_edge (new_bb);
+		  ne->goto_locus = e->goto_locus;
+		}
+	      if ((e->flags & (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL))
+		   && e->dest != EXIT_BLOCK_PTR_FOR_FN (cfun))
+		need_exit_edge = 1;
+	      if (e->dest == EXIT_BLOCK_PTR_FOR_FN (cfun))
+		have_exit_edge = 1;
+	    }
+	  FOR_EACH_EDGE (e, ei, bb->preds)
 	    {
-	      basic_block new_bb = split_edge (e);
-	      edge ne = single_succ_edge (new_bb);
-	      ne->goto_locus = e->goto_locus;
+	      if ((e->flags & (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL))
+		   && e->src != ENTRY_BLOCK_PTR_FOR_FN (cfun))
+		need_entry_edge = 1;
+	      if (e->src == ENTRY_BLOCK_PTR_FOR_FN (cfun))
+		have_entry_edge = 1;
 	    }
-	  if ((e->flags & (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL))
-	       && e->dest != EXIT_BLOCK_PTR_FOR_FN (cfun))
-	    need_exit_edge = 1;
-	  if (e->dest == EXIT_BLOCK_PTR_FOR_FN (cfun))
-	    have_exit_edge = 1;
-	}
-      FOR_EACH_EDGE (e, ei, bb->preds)
-	{
-	  if ((e->flags & (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL))
-	       && e->src != ENTRY_BLOCK_PTR_FOR_FN (cfun))
-	    need_entry_edge = 1;
-	  if (e->src == ENTRY_BLOCK_PTR_FOR_FN (cfun))
-	    have_entry_edge = 1;
-	}
 
-      if (need_exit_edge && !have_exit_edge)
-	{
-	  if (dump_file)
-	    fprintf (dump_file, "Adding fake exit edge to bb %i\n",
-		     bb->index);
-	  make_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun), EDGE_FAKE);
-	}
-      if (need_entry_edge && !have_entry_edge)
-	{
-	  if (dump_file)
-	    fprintf (dump_file, "Adding fake entry edge to bb %i\n",
-		     bb->index);
-	  make_edge (ENTRY_BLOCK_PTR_FOR_FN (cfun), bb, EDGE_FAKE);
-	  /* Avoid bbs that have both fake entry edge and also some
-	     exit edge.  One of those edges wouldn't be added to the
-	     spanning tree, but we can't instrument any of them.  */
-	  if (have_exit_edge || need_exit_edge)
+	  if (need_exit_edge && !have_exit_edge)
+	    {
+	      if (dump_file)
+		fprintf (dump_file, "Adding fake exit edge to bb %i\n",
+			 bb->index);
+	      make_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun), EDGE_FAKE);
+	    }
+	  if (need_entry_edge && !have_entry_edge)
 	    {
-	      gimple_stmt_iterator gsi;
-	      gimple *first;
-
-	      gsi = gsi_start_nondebug_after_labels_bb (bb);
-	      gcc_checking_assert (!gsi_end_p (gsi));
-	      first = gsi_stmt (gsi);
-	      /* Don't split the bbs containing __builtin_setjmp_receiver
-		 or ABNORMAL_DISPATCHER calls.  These are very
-		 special and don't expect anything to be inserted before
-		 them.  */
-	      if (is_gimple_call (first)
-		  && (gimple_call_builtin_p (first, BUILT_IN_SETJMP_RECEIVER)
-		      || (gimple_call_flags (first) & ECF_RETURNS_TWICE)
-		      || (gimple_call_internal_p (first)
-			  && (gimple_call_internal_fn (first)
-			      == IFN_ABNORMAL_DISPATCHER))))
-		continue;
-
 	      if (dump_file)
-		fprintf (dump_file, "Splitting bb %i after labels\n",
+		fprintf (dump_file, "Adding fake entry edge to bb %i\n",
 			 bb->index);
-	      split_block_after_labels (bb);
+	      make_edge (ENTRY_BLOCK_PTR_FOR_FN (cfun), bb, EDGE_FAKE);
+	      /* Avoid bbs that have both fake entry edge and also some
+		 exit edge.  One of those edges wouldn't be added to the
+		 spanning tree, but we can't instrument any of them.  */
+	      if (have_exit_edge || need_exit_edge)
+		{
+		  gimple_stmt_iterator gsi;
+		  gimple *first;
+
+		  gsi = gsi_start_nondebug_after_labels_bb (bb);
+		  gcc_checking_assert (!gsi_end_p (gsi));
+		  first = gsi_stmt (gsi);
+		  /* Don't split the bbs containing __builtin_setjmp_receiver
+		     or ABNORMAL_DISPATCHER calls.  These are very
+		     special and don't expect anything to be inserted before
+		     them.  */
+		  if (is_gimple_call (first)
+		      && (gimple_call_builtin_p (first, BUILT_IN_SETJMP_RECEIVER)
+			  || (gimple_call_flags (first) & ECF_RETURNS_TWICE)
+			  || (gimple_call_internal_p (first)
+			      && (gimple_call_internal_fn (first)
+				  == IFN_ABNORMAL_DISPATCHER))))
+		    continue;
+
+		  if (dump_file)
+		    fprintf (dump_file, "Splitting bb %i after labels\n",
+			     bb->index);
+		  split_block_after_labels (bb);
+		}
 	    }
 	}
     }
@@ -1155,7 +1177,18 @@ branch_prob (void)
      on the spanning tree.  We insert as many abnormal and critical edges
      as possible to minimize number of edge splits necessary.  */
 
-  find_spanning_tree (el);
+  if (!thunk)
+    find_spanning_tree (el);
+  else
+    {
+      edge e;
+      edge_iterator ei;
+      /* Keep only edge from entry block to be instrumented.  */
+      FOR_EACH_BB_FN (bb, cfun)
+	FOR_EACH_EDGE (e, ei, bb->succs)
+	  EDGE_INFO (e)->ignore = true;
+    }
+
 
   /* Fake edges that are not on the tree will not be instrumented, so
      mark them ignored.  */
@@ -1195,8 +1228,17 @@ branch_prob (void)
      the checksum in only once place, since it depends on the shape
      of the control flow which can change during 
      various transformations.  */
-  cfg_checksum = coverage_compute_cfg_checksum (cfun);
-  lineno_checksum = coverage_compute_lineno_checksum ();
+  if (thunk)
+    {
+      /* At stream in time we do not have CFG, so we can not do checksums.  */
+      cfg_checksum = 0;
+      lineno_checksum = 0;
+    }
+  else
+    {
+      cfg_checksum = coverage_compute_cfg_checksum (cfun);
+      lineno_checksum = coverage_compute_lineno_checksum ();
+    }
 
   /* Write the data from which gcov can reconstruct the basic block
      graph and function line numbers (the gcno file).  */
diff --git a/gcc/testsuite/g++.dg/tree-prof/devirt.C b/gcc/testsuite/g++.dg/tree-prof/devirt.C
index 86cba41452e..7d6797dd226 100644
--- a/gcc/testsuite/g++.dg/tree-prof/devirt.C
+++ b/gcc/testsuite/g++.dg/tree-prof/devirt.C
@@ -119,5 +119,5 @@ main ()
     __builtin_abort ();
 }
 
-/* { dg-final-use-not-autofdo { scan-tree-dump-times "folding virtual function call to virtual unsigned int mozPersonalDictionary::_ZThn16" 3 "dom3" } } */
-/* { dg-final-use-not-autofdo { scan-tree-dump-times "folding virtual function call to virtual unsigned int mozPersonalDictionary::AddRef" 3 "dom3" } } */
+/* { dg-final-use-not-autofdo { scan-tree-dump-times "folding virtual function call to virtual unsigned int mozPersonalDictionary::_ZThn16" 1 "dom3" } } */
+/* { dg-final-use-not-autofdo { scan-tree-dump-times "folding virtual function call to virtual unsigned int mozPersonalDictionary::AddRef" 1 "dom3" } } */
diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
index f96bd4b9704..8f8bb4874cd 100644
--- a/gcc/tree-profile.c
+++ b/gcc/tree-profile.c
@@ -653,7 +653,8 @@ tree_profiling (void)
 
   FOR_EACH_DEFINED_FUNCTION (node)
     {
-      if (!gimple_has_body_p (node->decl))
+      bool thunk = false;
+      if (!gimple_has_body_p (node->decl) && !node->thunk.thunk_p)
 	continue;
 
       /* Don't profile functions produced for builtin stuff.  */
@@ -670,22 +671,43 @@ tree_profiling (void)
 	  && flag_test_coverage)
 	continue;
 
+      if (node->thunk.thunk_p)
+	{
+	  /* We can not expand variadic thunks to Gimple.  */
+	  if (stdarg_p (TREE_TYPE (node->decl)))
+	    continue;
+	  thunk = true;
+	  /* When generate profile, expand thunk to gimple so it can be
+	     instrumented same way as other functions.  */
+	  if (profile_arc_flag)
+	    node->expand_thunk (false, true);
+	  /* Read cgraph profile but keep function as thunk at profile-use
+	     time.  */
+	  else
+	    {
+	      read_thunk_profile (node);
+	      continue;
+	    }
+	}
+
       push_cfun (DECL_STRUCT_FUNCTION (node->decl));
 
       if (dump_file)
 	dump_function_header (dump_file, cfun->decl, dump_flags);
 
       /* Local pure-const may imply need to fixup the cfg.  */
-      if (execute_fixup_cfg () & TODO_cleanup_cfg)
+      if (gimple_has_body_p (node->decl)
+	  && (execute_fixup_cfg () & TODO_cleanup_cfg))
 	cleanup_tree_cfg ();
 
-      branch_prob ();
+      branch_prob (thunk);
 
       if (! flag_branch_probabilities
 	  && flag_profile_values)
 	gimple_gen_ic_func_profiler ();
 
       if (flag_branch_probabilities
+	  && !thunk
 	  && flag_profile_values
 	  && flag_value_profile_transformations)
 	gimple_value_profile_transformations ();
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index 16cdbd64f46..d845faf5568 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -1202,7 +1202,7 @@ init_node_map (bool local)
   cgraph_node_map = new hash_map<profile_id_hash, cgraph_node *>;
 
   FOR_EACH_DEFINED_FUNCTION (n)
-    if (n->has_gimple_body_p ())
+    if (n->has_gimple_body_p () || n->thunk.thunk_p)
       {
 	cgraph_node **val;
 	if (local)
diff --git a/gcc/value-prof.h b/gcc/value-prof.h
index d0b8cda181f..55b1dd18416 100644
--- a/gcc/value-prof.h
+++ b/gcc/value-prof.h
@@ -112,7 +112,8 @@ extern struct cgraph_node* find_func_by_profile_id (int func_id);
 
 /* In profile.c.  */
 extern void init_branch_prob (void);
-extern void branch_prob (void);
+extern void branch_prob (bool);
+extern void read_thunk_profile (struct cgraph_node *);
 extern void end_branch_prob (void);
 
 #endif	/* GCC_VALUE_PROF_H */
-- 
2.20.1


[-- Attachment #4: 0001-Backport-r267486.patch --]
[-- Type: text/x-patch, Size: 1578 bytes --]

From eb618a86fa1f59ee7046c325a4a6acfc696cd990 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 31 Dec 2018 14:11:09 +0000
Subject: [PATCH 1/3] Backport r267486

gcc/testsuite/ChangeLog:

2018-12-31  Martin Liska  <mliska@suse.cz>

	* g++.dg/tree-prof/devirt.C: Fix scan pattern and test options.
---
 gcc/testsuite/g++.dg/tree-prof/devirt.C | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/g++.dg/tree-prof/devirt.C b/gcc/testsuite/g++.dg/tree-prof/devirt.C
index 05c9a26e7a4..86cba41452e 100644
--- a/gcc/testsuite/g++.dg/tree-prof/devirt.C
+++ b/gcc/testsuite/g++.dg/tree-prof/devirt.C
@@ -1,4 +1,4 @@
-/* { dg-options "-O3 -fdump-tree-dom3" } */
+/* { dg-options "-O3 -fdump-tree-dom3-details" } */
 struct nsISupports
 {
   virtual int QueryInterface (const int &aIID, void **aInstancePtr) = 0;
@@ -119,5 +119,5 @@ main ()
     __builtin_abort ();
 }
 
-/* { dg-final-use-not-autofdo { scan-ipa-dump-times 3 "folding virtual function call to virtual unsigned int mozPersonalDictionary::_ZThn16" "dom3" } } */
-/* { dg-final-use-not-autofdo { scan-ipa-dump-times 3 "folding virtual function call to virtual unsigned int mozPersonalDictionary::AddRef" "dom3" } } */
+/* { dg-final-use-not-autofdo { scan-tree-dump-times "folding virtual function call to virtual unsigned int mozPersonalDictionary::_ZThn16" 3 "dom3" } } */
+/* { dg-final-use-not-autofdo { scan-tree-dump-times "folding virtual function call to virtual unsigned int mozPersonalDictionary::AddRef" 3 "dom3" } } */
-- 
2.20.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2018-11-20 10:58         ` Martin Liška
  2018-12-27 14:59           ` Martin Liška
@ 2019-02-14 11:23           ` Martin Liška
  2019-02-14 13:57             ` Martin Liška
  1 sibling, 1 reply; 26+ messages in thread
From: Martin Liška @ 2019-02-14 11:23 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 393 bytes --]

On 11/20/18 11:58 AM, Martin Liška wrote:
> On 10/3/18 11:23 AM, Martin Liška wrote:
>> On 9/25/18 8:48 AM, Martin Liška wrote:
>>> Hi.
>>>
>>> One more tested patch.
>>>
>>> Martin
>>>
>>
>> One more tested patch.
>>
>> Martin
>>
> 
> Hi.
> 
> One another tested patch that I'm going to install.
> 
> Martin
> 

Hi.

Another 2 patches that I've just tested and will install.

Martin

[-- Attachment #2: 0001-Backport-r268762.patch --]
[-- Type: text/x-patch, Size: 6214 bytes --]

From 65c43b0a4fb210485ad01d5f55573bfc0f17441d Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 11 Feb 2019 08:13:03 +0000
Subject: [PATCH 1/2] Backport r268762

gcc/ChangeLog:

2019-02-11  Martin Liska  <mliska@suse.cz>

	PR ipa/89009
	* ipa-cp.c (build_toporder_info): Remove usage of a param.
	* ipa-inline.c (inline_small_functions): Likewise.
	* ipa-pure-const.c (propagate_pure_const): Likewise.
	(propagate_nothrow): Likewise.
	* ipa-reference.c (propagate): Likewise.
	* ipa-utils.c (struct searchc_env): Remove unused field.
	(searchc): Always search across AVAIL_INTERPOSABLE.
	(ipa_reduced_postorder): Always allow AVAIL_INTERPOSABLE as
	the only called IPA pure const can properly not propagate
	across interposable boundary.
	* ipa-utils.h (ipa_reduced_postorder): Remove param.

gcc/testsuite/ChangeLog:

2019-02-11  Martin Liska  <mliska@suse.cz>

	PR ipa/89009
	* g++.dg/ipa/pr89009.C: New test.
---
 gcc/ipa-cp.c                       |  2 +-
 gcc/ipa-inline.c                   |  2 +-
 gcc/ipa-pure-const.c               |  4 ++--
 gcc/ipa-reference.c                |  2 +-
 gcc/ipa-utils.c                    |  9 +++------
 gcc/ipa-utils.h                    |  2 +-
 gcc/testsuite/g++.dg/ipa/pr89009.C | 12 ++++++++++++
 7 files changed, 21 insertions(+), 12 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/ipa/pr89009.C

diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index e868b9c2623..5bd4df0ecb7 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -820,7 +820,7 @@ build_toporder_info (struct ipa_topo_info *topo)
   topo->stack = XCNEWVEC (struct cgraph_node *, symtab->cgraph_count);
 
   gcc_checking_assert (topo->stack_top == 0);
-  topo->nnodes = ipa_reduced_postorder (topo->order, true, true, NULL);
+  topo->nnodes = ipa_reduced_postorder (topo->order, true, NULL);
 }
 
 /* Free information about strongly connected components and the arrays in
diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
index 996b04cb81d..bde7ecfd0d5 100644
--- a/gcc/ipa-inline.c
+++ b/gcc/ipa-inline.c
@@ -1759,7 +1759,7 @@ inline_small_functions (void)
      metrics.  */
 
   max_count = profile_count::uninitialized ();
-  ipa_reduced_postorder (order, true, true, NULL);
+  ipa_reduced_postorder (order, true, NULL);
   free (order);
 
   FOR_EACH_DEFINED_FUNCTION (node)
diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
index a80b6845633..d36d1ba9b73 100644
--- a/gcc/ipa-pure-const.c
+++ b/gcc/ipa-pure-const.c
@@ -1443,7 +1443,7 @@ propagate_pure_const (void)
   bool remove_p = false;
   bool has_cdtor;
 
-  order_pos = ipa_reduced_postorder (order, true, false,
+  order_pos = ipa_reduced_postorder (order, true,
 				     ignore_edge_for_pure_const);
   if (dump_file)
     {
@@ -1773,7 +1773,7 @@ propagate_nothrow (void)
   int i;
   struct ipa_dfs_info * w_info;
 
-  order_pos = ipa_reduced_postorder (order, true, false,
+  order_pos = ipa_reduced_postorder (order, true,
 				     ignore_edge_for_nothrow);
   if (dump_file)
     {
diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c
index 6490c03f8d0..b9db61697d1 100644
--- a/gcc/ipa-reference.c
+++ b/gcc/ipa-reference.c
@@ -728,7 +728,7 @@ propagate (void)
      the global information.  All the nodes within a cycle will have
      the same info so we collapse cycles first.  Then we can do the
      propagation in one pass from the leaves to the roots.  */
-  order_pos = ipa_reduced_postorder (order, true, true, ignore_edge_p);
+  order_pos = ipa_reduced_postorder (order, true, ignore_edge_p);
   if (dump_file)
     ipa_print_order (dump_file, "reduced", order, order_pos);
 
diff --git a/gcc/ipa-utils.c b/gcc/ipa-utils.c
index a271bb822cb..106d3079391 100644
--- a/gcc/ipa-utils.c
+++ b/gcc/ipa-utils.c
@@ -63,7 +63,6 @@ struct searchc_env {
   int order_pos;
   splay_tree nodes_marked_new;
   bool reduce;
-  bool allow_overwritable;
   int count;
 };
 
@@ -105,7 +104,7 @@ searchc (struct searchc_env* env, struct cgraph_node *v,
 
       if (w->aux
 	  && (avail > AVAIL_INTERPOSABLE
-	      || (env->allow_overwritable && avail == AVAIL_INTERPOSABLE)))
+	      || avail == AVAIL_INTERPOSABLE))
 	{
 	  w_info = (struct ipa_dfs_info *) w->aux;
 	  if (w_info->new_node)
@@ -162,7 +161,7 @@ searchc (struct searchc_env* env, struct cgraph_node *v,
 
 int
 ipa_reduced_postorder (struct cgraph_node **order,
-		       bool reduce, bool allow_overwritable,
+		       bool reduce,
 		       bool (*ignore_edge) (struct cgraph_edge *))
 {
   struct cgraph_node *node;
@@ -175,15 +174,13 @@ ipa_reduced_postorder (struct cgraph_node **order,
   env.nodes_marked_new = splay_tree_new (splay_tree_compare_ints, 0, 0);
   env.count = 1;
   env.reduce = reduce;
-  env.allow_overwritable = allow_overwritable;
 
   FOR_EACH_DEFINED_FUNCTION (node)
     {
       enum availability avail = node->get_availability ();
 
       if (avail > AVAIL_INTERPOSABLE
-	  || (allow_overwritable
-	      && (avail == AVAIL_INTERPOSABLE)))
+	  || avail == AVAIL_INTERPOSABLE)
 	{
 	  /* Reuse the info if it is already there.  */
 	  struct ipa_dfs_info *info = (struct ipa_dfs_info *) node->aux;
diff --git a/gcc/ipa-utils.h b/gcc/ipa-utils.h
index 1609ac14d7f..e247d63fd7e 100644
--- a/gcc/ipa-utils.h
+++ b/gcc/ipa-utils.h
@@ -36,7 +36,7 @@ struct ipa_dfs_info {
 
 /* In ipa-utils.c  */
 void ipa_print_order (FILE*, const char *, struct cgraph_node**, int);
-int ipa_reduced_postorder (struct cgraph_node **, bool, bool,
+int ipa_reduced_postorder (struct cgraph_node **, bool,
 			  bool (*ignore_edge) (struct cgraph_edge *));
 void ipa_free_postorder_info (void);
 vec<cgraph_node *> ipa_get_nodes_in_cycle (struct cgraph_node *);
diff --git a/gcc/testsuite/g++.dg/ipa/pr89009.C b/gcc/testsuite/g++.dg/ipa/pr89009.C
new file mode 100644
index 00000000000..6b4fc65a641
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr89009.C
@@ -0,0 +1,12 @@
+/* PR ipa/89009 */
+/* { dg-do run } */
+/* { dg-options "-fvisibility=hidden -fpic -O2 -fno-inline" } */
+
+#pragma GCC visibility push(default)
+void foo1() { __builtin_printf ("foo\n"); }
+#pragma GCC visibility pop
+void foo2() { __builtin_printf ("foo\n"); }
+
+int main() { foo2(); return 0; }
+
+/* { dg-output "foo" } */
-- 
2.20.1


[-- Attachment #3: 0002-Backport-r268835.patch --]
[-- Type: text/x-patch, Size: 2709 bytes --]

From 947e8b02e187f56873b9cce665603fbc5815b6c8 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 13 Feb 2019 06:57:38 +0000
Subject: [PATCH 2/2] Backport r268835

gcc/ChangeLog:

2019-02-13  Martin Liska  <mliska@suse.cz>

	PR lto/88858
	* cfgrtl.c (remove_barriers_from_footer): New function.
	(try_redirect_by_replacing_jump): Use it.
	(cfg_layout_redirect_edge_and_branch): Likewise.
---
 gcc/cfgrtl.c | 46 +++++++++++++++++++++++++++-------------------
 1 file changed, 27 insertions(+), 19 deletions(-)

diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index 7af4191da77..f6e4fecd647 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -984,6 +984,31 @@ block_label (basic_block block)
   return as_a <rtx_code_label *> (BB_HEAD (block));
 }
 
+/* Remove all barriers from BB_FOOTER of a BB.  */
+
+static void
+remove_barriers_from_footer (basic_block bb)
+{
+  rtx_insn *insn = BB_FOOTER (bb);
+
+  /* Remove barriers but keep jumptables.  */
+  while (insn)
+    {
+      if (BARRIER_P (insn))
+	{
+	  if (PREV_INSN (insn))
+	    SET_NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn);
+	  else
+	    BB_FOOTER (bb) = NEXT_INSN (insn);
+	  if (NEXT_INSN (insn))
+	    SET_PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn);
+	}
+      if (LABEL_P (insn))
+	return;
+      insn = NEXT_INSN (insn);
+    }
+}
+
 /* Attempt to perform edge redirection by replacing possibly complex jump
    instruction by unconditional jump or removing jump completely.  This can
    apply only if all edges now point to the same block.  The parameters and
@@ -1047,26 +1072,8 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout)
       /* Selectively unlink whole insn chain.  */
       if (in_cfglayout)
 	{
-	  rtx_insn *insn = BB_FOOTER (src);
-
 	  delete_insn_chain (kill_from, BB_END (src), false);
-
-	  /* Remove barriers but keep jumptables.  */
-	  while (insn)
-	    {
-	      if (BARRIER_P (insn))
-		{
-		  if (PREV_INSN (insn))
-		    SET_NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn);
-		  else
-		    BB_FOOTER (src) = NEXT_INSN (insn);
-		  if (NEXT_INSN (insn))
-		    SET_PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn);
-		}
-	      if (LABEL_P (insn))
-		break;
-	      insn = NEXT_INSN (insn);
-	    }
+	  remove_barriers_from_footer (src);
 	}
       else
 	delete_insn_chain (kill_from, PREV_INSN (BB_HEAD (target)),
@@ -4379,6 +4386,7 @@ cfg_layout_redirect_edge_and_branch (edge e, basic_block dest)
 	  	 "Removing crossing jump while redirecting edge form %i to %i\n",
 		 e->src->index, dest->index);
       delete_insn (BB_END (src));
+      remove_barriers_from_footer (src);
       e->flags |= EDGE_FALLTHRU;
     }
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2019-02-14 11:23           ` Martin Liška
@ 2019-02-14 13:57             ` Martin Liška
  2019-03-11  9:39               ` Martin Liška
  0 siblings, 1 reply; 26+ messages in thread
From: Martin Liška @ 2019-02-14 13:57 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 495 bytes --]

On 2/14/19 12:23 PM, Martin Liška wrote:
> On 11/20/18 11:58 AM, Martin Liška wrote:
>> On 10/3/18 11:23 AM, Martin Liška wrote:
>>> On 9/25/18 8:48 AM, Martin Liška wrote:
>>>> Hi.
>>>>
>>>> One more tested patch.
>>>>
>>>> Martin
>>>>
>>>
>>> One more tested patch.
>>>
>>> Martin
>>>
>>
>> Hi.
>>
>> One another tested patch that I'm going to install.
>>
>> Martin
>>
> 
> Hi.
> 
> Another 2 patches that I've just tested and will install.
> 
> Martin
> 

One more patch.

Martin

[-- Attachment #2: 0001-Backport-r268873.patch --]
[-- Type: text/x-patch, Size: 919 bytes --]

From a434c00b2d9a540152ea149244fa8df97f64def4 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Thu, 14 Feb 2019 14:25:48 +0100
Subject: [PATCH] Backport r268873

gcc/ChangeLog:

2019-02-14  Martin Liska  <mliska@suse.cz>

	PR rtl-optimization/89242
	* dce.c (delete_unmarked_insns): Call free_dominance_info we
	process a transformation.

gcc/testsuite/ChangeLog:

2019-02-14  Martin Liska  <mliska@suse.cz>

	PR rtl-optimization/89242
	* g++.dg/pr89242.C: New test.
---
 gcc/dce.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/dce.c b/gcc/dce.c
index 2ef4dd7bd3b..ce2edc43efb 100644
--- a/gcc/dce.c
+++ b/gcc/dce.c
@@ -642,7 +642,10 @@ delete_unmarked_insns (void)
 
   /* Deleted a pure or const call.  */
   if (must_clean)
-    delete_unreachable_blocks ();
+    {
+      delete_unreachable_blocks ();
+      free_dominance_info (CDI_DOMINATORS);
+    }
 }
 
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2019-02-14 13:57             ` Martin Liška
@ 2019-03-11  9:39               ` Martin Liška
  2019-03-15  8:39                 ` Martin Liška
  0 siblings, 1 reply; 26+ messages in thread
From: Martin Liška @ 2019-03-11  9:39 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 64 bytes --]

Hi.

I'm sending another patches that I've just tested.

Martin

[-- Attachment #2: 0004-Backport-r269558.patch --]
[-- Type: text/x-patch, Size: 1157 bytes --]

From 915af267eb22e5059737f4dbb6e9d48601bb0779 Mon Sep 17 00:00:00 2001
From: "ro@138bc75d-0d04-0410-961f-82ee72b054a4"
 <ro@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Sun, 10 Mar 2019 16:43:48 +0000
Subject: [PATCH 4/4] Backport r269558

gcc/testsuite/ChangeLog:

2019-03-10  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* gcc.target/i386/indirect-thunk-extern-7.c: Add -fjump-tables to
	dg-options.
---
 gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c
index b7339745116..95c5cc176ae 100644
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic -fjump-tables" } */
 
 void func0 (void);
 void func1 (void);
-- 
2.21.0


[-- Attachment #3: 0003-Backport-r269492.patch --]
[-- Type: text/x-patch, Size: 2649 bytes --]

From 5a433aca1d83cfc8a270b02d89be5b3ed75a503c Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 8 Mar 2019 12:55:40 +0000
Subject: [PATCH 3/4] Backport r269492

gcc/ChangeLog:

2019-03-08  Martin Liska  <mliska@suse.cz>

	PR target/86952
	* config/i386/i386.c (ix86_option_override_internal): Disable
	jump tables when retpolines are used.

gcc/testsuite/ChangeLog:

2019-03-08  Martin Liska  <mliska@suse.cz>

	PR target/86952
	* gcc.target/i386/indirect-thunk-7.c: Use jump tables to match
	scanned pattern.
	* gcc.target/i386/indirect-thunk-inline-7.c: Likewise.
---
 gcc/config/i386/i386.c                                  | 6 ++++++
 gcc/testsuite/gcc.target/i386/indirect-thunk-7.c        | 2 +-
 gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c | 2 +-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index a88a29b51e6..f1de97f73df 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -4958,6 +4958,12 @@ ix86_option_override_internal (bool main_args_p,
 			   opts->x_param_values,
 			   opts_set->x_param_values);
 
+  /* PR86952: jump table usage with retpolines is slow.
+     The PR provides some numbers about the slowness.  */
+  if (ix86_indirect_branch != indirect_branch_keep
+      && !opts_set->x_flag_jump_tables)
+    opts->x_flag_jump_tables = 0;
+
   return true;
 }
 
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c
index 3c72036dbaf..53868f46558 100644
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic -fjump-tables" } */
 
 void func0 (void);
 void func1 (void);
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c
index ea009245a58..e6f064959a1 100644
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic -fjump-tables" } */
 
 void func0 (void);
 void func1 (void);
-- 
2.21.0


[-- Attachment #4: 0002-Backport-r268981.patch --]
[-- Type: text/x-patch, Size: 1126 bytes --]

From 4a20f76e3887229751ebd8352cc3c77a4e7c2b10 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 18 Feb 2019 09:46:19 +0000
Subject: [PATCH 2/4] Backport r268981

libcpp/ChangeLog:

2019-02-18  Martin Liska  <mliska@suse.cz>

	PR c++/89383
	* line-map.c (linemap_line_start): Use 1UL in order
	to not overflow.
---
 libcpp/line-map.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libcpp/line-map.c b/libcpp/line-map.c
index 42aecd6993f..72fe2c0dcec 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -758,7 +758,8 @@ linemap_line_start (struct line_maps *set, linenum_type to_line,
 	  || ( /* We can't reuse the map if the line offset is sufficiently
 		  large to cause overflow when computing location_t values.  */
 	      (to_line - ORDINARY_MAP_STARTING_LINE_NUMBER (map))
-	      >= (1U << (CHAR_BIT * sizeof (linenum_type) - column_bits)))
+	      >= (((uint64_t) 1)
+		  << (CHAR_BIT * sizeof (linenum_type) - column_bits)))
 	  || range_bits < map->m_range_bits)
 	map = linemap_check_ordinary
 	        (const_cast <line_map *>
-- 
2.21.0


[-- Attachment #5: 0001-Backport-r268789.patch --]
[-- Type: text/x-patch, Size: 3133 bytes --]

From fe9fa030d7ae1a4b4da4751b39bddc68395b1728 Mon Sep 17 00:00:00 2001
From: dmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 12 Feb 2019 01:09:31 +0000
Subject: [PATCH 1/4] Backport r268789

gcc/ChangeLog:

2019-02-11  David Malcolm  <dmalcolm@redhat.com>

	PR lto/88147
	* input.c (selftest::test_line_offset_overflow): New selftest.
	(selftest::input_c_tests): Call it.

libcpp/ChangeLog:

2019-02-11  Martin Liska  <mliska@suse.cz>

	PR lto/88147
	* line-map.c (linemap_line_start): Don't reuse the existing line
	map if the line offset is sufficiently large to cause overflow
	when computing location_t values.
---
 gcc/input.c       | 30 ++++++++++++++++++++++++++++++
 libcpp/line-map.c |  4 ++++
 2 files changed, 34 insertions(+)

diff --git a/gcc/input.c b/gcc/input.c
index b6675768722..26c2bf21d52 100644
--- a/gcc/input.c
+++ b/gcc/input.c
@@ -3538,6 +3538,34 @@ for_each_line_table_case (void (*testcase) (const line_table_case &))
   ASSERT_EQ (num_cases_tested, 2 * 12);
 }
 
+/* Verify that when presented with a consecutive pair of locations with
+   a very large line offset, we don't attempt to consolidate them into
+   a single ordinary linemap where the line offsets within the line map
+   would lead to overflow (PR lto/88147).  */
+
+static void
+test_line_offset_overflow ()
+{
+  line_table_test ltt (line_table_case (5, 0));
+
+  linemap_add (line_table, LC_ENTER, false, "foo.c", 0);
+  linemap_line_start (line_table, 1, 100);
+  location_t loc_a = linemap_line_start (line_table, 2578, 255);
+  assert_loceq ("foo.c", 2578, 0, loc_a);
+
+  const line_map_ordinary *ordmap_a = LINEMAPS_LAST_ORDINARY_MAP (line_table);
+  ASSERT_EQ (ordmap_a->m_column_and_range_bits, 13);
+  ASSERT_EQ (ordmap_a->m_range_bits, 5);
+
+  location_t loc_b = linemap_line_start (line_table, 404198, 512);
+  assert_loceq ("foo.c", 404198, 0, loc_b);
+
+  /* We should have started a new linemap, rather than attempting to store
+     a very large line offset.  */
+  const line_map_ordinary *ordmap_b = LINEMAPS_LAST_ORDINARY_MAP (line_table);
+  ASSERT_NE (ordmap_a, ordmap_b);
+}
+
 /* Run all of the selftests within this file.  */
 
 void
@@ -3577,6 +3605,8 @@ input_c_tests ()
   for_each_line_table_case (test_lexer_char_constants);
 
   test_reading_source_line ();
+
+  test_line_offset_overflow ();
 }
 
 } // namespace selftest
diff --git a/libcpp/line-map.c b/libcpp/line-map.c
index a84084c99f0..42aecd6993f 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -755,6 +755,10 @@ linemap_line_start (struct line_maps *set, linenum_type to_line,
       if (line_delta < 0
 	  || last_line != ORDINARY_MAP_STARTING_LINE_NUMBER (map)
 	  || SOURCE_COLUMN (map, highest) >= (1U << (column_bits - range_bits))
+	  || ( /* We can't reuse the map if the line offset is sufficiently
+		  large to cause overflow when computing location_t values.  */
+	      (to_line - ORDINARY_MAP_STARTING_LINE_NUMBER (map))
+	      >= (1U << (CHAR_BIT * sizeof (linenum_type) - column_bits)))
 	  || range_bits < map->m_range_bits)
 	map = linemap_check_ordinary
 	        (const_cast <line_map *>
-- 
2.21.0


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2019-03-11  9:39               ` Martin Liška
@ 2019-03-15  8:39                 ` Martin Liška
  2019-03-28  8:53                   ` Martin Liška
  0 siblings, 1 reply; 26+ messages in thread
From: Martin Liška @ 2019-03-15  8:39 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 43 bytes --]

Hi.

One more documentation patch.

Martin

[-- Attachment #2: 0001-patch-269684.patch --]
[-- Type: text/x-patch, Size: 880 bytes --]

From 12a1a2bf98075d79d60189d3d3b4d6c3de79a877 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 14 Mar 2019 14:19:33 +0000
Subject: Backport r269684

gcc/ChangeLog:

2019-03-14  Martin Liska  <mliska@suse.cz>

	PR other/89712
	* doc/invoke.texi: Remove -fdump-class-hierarchy option.

---
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index df0883f2fc9..0a941519dbc 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -583,7 +583,6 @@ Objective-C and Objective-C++ Dialects}.
 -fdisable-tree-@var{pass-name}=@var{range-list} @gol
 -fdump-debug  -fdump-earlydebug @gol
 -fdump-noaddr  -fdump-unnumbered  -fdump-unnumbered-links @gol
--fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol
 -fdump-final-insns@r{[}=@var{file}@r{]} @gol
 -fdump-ipa-all  -fdump-ipa-cgraph  -fdump-ipa-inline @gol
 -fdump-lang-all @gol
--
2.21.0

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2019-03-15  8:39                 ` Martin Liška
@ 2019-03-28  8:53                   ` Martin Liška
  2019-05-24  7:42                     ` Martin Liška
  0 siblings, 1 reply; 26+ messages in thread
From: Martin Liška @ 2019-03-28  8:53 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 50 bytes --]

Hi.

I'm backporting a documentation fix.

Martin

[-- Attachment #2: 0001-Backport-r265786.patch --]
[-- Type: text/x-patch, Size: 1063 bytes --]

From 1055e2c2787be337c33787608473a7a4bcbe82b8 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Thu, 28 Mar 2019 09:47:27 +0100
Subject: [PATCH] Backport r265786

gcc/ChangeLog:

2018-11-05  Martin Liska  <mliska@suse.cz>

	PR web/87829
	* doc/invoke.texi: Remove options that are
	not disabled with -Os.
---
 gcc/doc/invoke.texi | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 4ee24c3ab78..de86d7a1e01 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -7680,8 +7680,7 @@ do not typically increase code size.
 
 @option{-Os} disables the following optimization flags:
 @gccoptlist{-falign-functions  -falign-jumps  -falign-loops @gol
--falign-labels  -freorder-blocks  -freorder-blocks-algorithm=stc @gol
--freorder-blocks-and-partition  -fprefetch-loop-arrays}
+-falign-labels  -fprefetch-loop-arrays}
 
 It also enables @option{-finline-functions}, causes the compiler to tune for
 code size rather than execution speed, and performs further optimizations
-- 
2.21.0


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2019-03-28  8:53                   ` Martin Liška
@ 2019-05-24  7:42                     ` Martin Liška
  2019-07-04 10:17                       ` Martin Liška
  0 siblings, 1 reply; 26+ messages in thread
From: Martin Liška @ 2019-05-24  7:42 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 58 bytes --]

Hi.

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

Martin

[-- Attachment #2: 0001-Backport-r271548.patch --]
[-- Type: text/x-patch, Size: 1572 bytes --]

From 3a0412967ede61515ce59230580558f5531e63f6 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 23 May 2019 10:12:01 +0000
Subject: [PATCH] Backport r271548

gcc/ChangeLog:

2019-05-23  Martin Liska  <mliska@suse.cz>

	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  <mliska@suse.cz>

	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 bdb15a8fd14..2971293a720 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -6653,6 +6653,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 00000000000..c2366905516
--- /dev/null
+++ b/gcc/testsuite/g++.dg/asan/pr90570.C
@@ -0,0 +1,18 @@
+/* PR sanitizer/90570 */
+/* { dg-do run } */
+
+#include <vector>
+
+struct stru
+{
+  std::vector<int> v{1,2,3,4};
+  int i{5};
+};
+
+int main()
+{
+  stru s1;
+  stru s2;
+
+  return 0;
+}
-- 
2.21.0


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2019-05-24  7:42                     ` Martin Liška
@ 2019-07-04 10:17                       ` Martin Liška
  0 siblings, 0 replies; 26+ messages in thread
From: Martin Liška @ 2019-07-04 10:17 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 53 bytes --]

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

Martin

[-- Attachment #2: 0001-Backport-r272992.patch --]
[-- Type: text/x-patch, Size: 1689 bytes --]

From 44e3202c0416fcaa5a145c32118f0d08ff8ea0a2 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 3 Jul 2019 08:31:35 +0000
Subject: [PATCH] Backport r272992

gcc/ChangeLog:

2019-07-03  Martin Liska  <mliska@suse.cz>

	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  <mliska@suse.cz>

	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 87000dba214..97d2268663f 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 00000000000..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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2018-05-23  8:43 GCC 8 backports Martin Liška
  2018-08-16 10:14 ` Martin Liška
@ 2020-01-15 10:15 ` Martin Liška
  2020-03-02  9:33 ` Martin Liška
  2020-03-29 17:17 ` Martin Liška
  3 siblings, 0 replies; 26+ messages in thread
From: Martin Liška @ 2020-01-15 10:15 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 78 bytes --]

Hi.

There's one more backport commit I've just tested and installed.

Martin

[-- Attachment #2: 0001-Backport-d2a0371d2641e85c5e6ca396029be32204d976df.patch --]
[-- Type: text/x-patch, Size: 2993 bytes --]

From 67c0ee2c48a5e154bf00fa8326536881a92e287c Mon Sep 17 00:00:00 2001
From: Jan Hubicka <hubicka@ucw.cz>
Date: Sun, 14 Apr 2019 22:56:45 +0200
Subject: [PATCH] Backport d2a0371d2641e85c5e6ca396029be32204d976df

gcc/ChangeLog:

2019-04-14  Jan Hubicka  <hubicka@ucw.cz>

	PR lto/89358
	* ipa-devirt.c (skip_in_fields_list_p): New.
	(odr_types_equivalent_p): Use it.

gcc/testsuite/ChangeLog:

2019-04-14  Jan Hubicka  <hubicka@ucw.cz>

	PR lto/89358
	* g++.dg/lto/pr89358_0.C: New testcase.
	* g++.dg/lto/pr89358_1.C: New testcase.
---
 gcc/ipa-devirt.c                     | 22 ++++++++++++++++++++--
 gcc/testsuite/g++.dg/lto/pr89358_0.C | 11 +++++++++++
 gcc/testsuite/g++.dg/lto/pr89358_1.C |  7 +++++++
 3 files changed, 38 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/lto/pr89358_0.C
 create mode 100644 gcc/testsuite/g++.dg/lto/pr89358_1.C

diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
index 5b6b130fa3a..380102020f9 100644
--- a/gcc/ipa-devirt.c
+++ b/gcc/ipa-devirt.c
@@ -1241,6 +1241,24 @@ warn_types_mismatch (tree t1, tree t2, location_t loc1, location_t loc2)
     inform (loc_t2, "the incompatible type is defined here");
 }
 
+/* Return true if T should be ignored in TYPE_FIELDS for ODR comparsion.  */
+
+static bool
+skip_in_fields_list_p (tree t)
+{
+  if (TREE_CODE (t) != FIELD_DECL)
+    return true;
+  /* C++ FE introduces zero sized fields depending on -std setting, see
+     PR89358.  */
+  if (DECL_SIZE (t)
+      && integer_zerop (DECL_SIZE (t))
+      && DECL_ARTIFICIAL (t)
+      && DECL_IGNORED_P (t)
+      && !DECL_NAME (t))
+    return true;
+  return false;
+}
+
 /* Compare T1 and T2, report ODR violations if WARN is true and set
    WARNED to true if anything is reported.  Return true if types match.
    If true is returned, the types are also compatible in the sense of
@@ -1525,9 +1543,9 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
 		 f1 = TREE_CHAIN (f1), f2 = TREE_CHAIN (f2))
 	      {
 		/* Skip non-fields.  */
-		while (f1 && TREE_CODE (f1) != FIELD_DECL)
+		while (f1 && skip_in_fields_list_p (f1))
 		  f1 = TREE_CHAIN (f1);
-		while (f2 && TREE_CODE (f2) != FIELD_DECL)
+		while (f2 && skip_in_fields_list_p (f2))
 		  f2 = TREE_CHAIN (f2);
 		if (!f1 || !f2)
 		  break;
diff --git a/gcc/testsuite/g++.dg/lto/pr89358_0.C b/gcc/testsuite/g++.dg/lto/pr89358_0.C
new file mode 100644
index 00000000000..aebd2127c0c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lto/pr89358_0.C
@@ -0,0 +1,11 @@
+/* { dg-do link } */
+/* { dg-options "-std=c++17"  } */
+#include <map>
+
+extern void test();
+
+int main()
+{
+        std::map<int, int> m;
+        test();
+}
diff --git a/gcc/testsuite/g++.dg/lto/pr89358_1.C b/gcc/testsuite/g++.dg/lto/pr89358_1.C
new file mode 100644
index 00000000000..68b80a37662
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lto/pr89358_1.C
@@ -0,0 +1,7 @@
+/* { dg-options "-std=c++14"  } */
+#include <map>
+
+void test()
+{
+        std::map<int, int> m;
+}
-- 
2.24.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2018-05-23  8:43 GCC 8 backports Martin Liška
  2018-08-16 10:14 ` Martin Liška
  2020-01-15 10:15 ` Martin Liška
@ 2020-03-02  9:33 ` Martin Liška
  2020-03-29 17:17 ` Martin Liška
  3 siblings, 0 replies; 26+ messages in thread
From: Martin Liška @ 2020-03-02  9:33 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 90 bytes --]

Hi.

There's one patch that was approved by Jakub before
another RC of GCC 8.4.0.

Martin

[-- Attachment #2: 0001-Backport-08bf7bde9f2987b1c623d272cc71fc14a1622442.patch --]
[-- Type: text/x-patch, Size: 1919 bytes --]

From 5da6f38276fac87c89d86e0d447aefb7058d1880 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Fri, 28 Feb 2020 17:52:57 +0100
Subject: [PATCH] Backport 08bf7bde9f2987b1c623d272cc71fc14a1622442

gcc/ChangeLog:

2020-02-28  Martin Liska  <mliska@suse.cz>

	PR other/93965
	* configure.ac: Improve detection of ld_date by requiring
	either two dashes or none.
	* configure: Regenerate.
---
 gcc/configure    | 2 +-
 gcc/configure.ac | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/configure b/gcc/configure
index 7313088fc2c..97ba7d7d69c 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -22785,7 +22785,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 9bed32ad43f..d6f2d5b2ed0 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -2580,7 +2580,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.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2018-05-23  8:43 GCC 8 backports Martin Liška
                   ` (2 preceding siblings ...)
  2020-03-02  9:33 ` Martin Liška
@ 2020-03-29 17:17 ` Martin Liška
  2020-04-03 10:32   ` Martin Liška
  3 siblings, 1 reply; 26+ messages in thread
From: Martin Liška @ 2020-03-29 17:17 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 59 bytes --]

Hi.

There's one more patch that I've just tested.

Martin

[-- Attachment #2: 0001-Backport-9297e013293e4d332fc7c40859ea4dd9616e0d88.patch --]
[-- Type: text/x-patch, Size: 2047 bytes --]

From 0e8def2b6dac1e7e46e6310ded21283914e05748 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Mon, 2 Sep 2019 09:06:54 +0200
Subject: [PATCH] Backport 9297e013293e4d332fc7c40859ea4dd9616e0d88

gcc/ChangeLog:

2019-09-02  Martin Liska  <mliska@suse.cz>

	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 a99802079dc..565530d4f73 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -653,10 +653,10 @@ unblock (const block_info *u, block_vector_t &blocked,
 /* Return true when PATH contains a zero cycle arc count.  */
 
 static bool
-path_contains_zero_cycle_arc (arc_vector_t &path)
+path_contains_zero_or_negative_cycle_arc (arc_vector_t &path)
 {
   for (unsigned i = 0; i < path.size (); i++)
-    if (path[i]->cs_count == 0)
+    if (path[i]->cs_count <= 0)
       return true;
   return false;
 }
@@ -682,7 +682,7 @@ circuit (block_info *v, arc_vector_t &path, block_info *start,
     {
       block_info *w = arc->dst;
       if (w < start
-	  || arc->cs_count == 0
+	  || arc->cs_count <= 0
 	  || !linfo.has_block (w))
 	continue;
 
@@ -693,7 +693,7 @@ circuit (block_info *v, arc_vector_t &path, 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);
@@ -708,7 +708,7 @@ circuit (block_info *v, arc_vector_t &path, 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.26.0


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2020-03-29 17:17 ` Martin Liška
@ 2020-04-03 10:32   ` Martin Liška
  0 siblings, 0 replies; 26+ messages in thread
From: Martin Liška @ 2020-04-03 10:32 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 43 bytes --]

Hi.

There's one more I've tested.

Martin

[-- Attachment #2: 0001-Backport-55a7380213a5c16120d5c674fb42b38a3d796b57.patch --]
[-- Type: text/x-patch, Size: 1291 bytes --]

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

gcc/ChangeLog:

2020-04-03  Martin Liska  <mliska@suse.cz>

	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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2019-05-14  9:11 ` Martin Liška
@ 2019-07-22  9:36   ` Martin Liška
  0 siblings, 0 replies; 26+ messages in thread
From: Martin Liška @ 2019-07-22  9:36 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 46 bytes --]

Hi.

One more patch I've just tested.

Martin

[-- Attachment #2: 0001-Backport-r273660.patch --]
[-- Type: text/x-patch, Size: 2755 bytes --]

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

gcc/ChangeLog:

2019-07-22  Martin Liska  <mliska@suse.cz>

	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  <mliska@suse.cz>

	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
+	    = &cl_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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: GCC 8 backports
  2019-05-06 14:00 Martin Liška
@ 2019-05-14  9:11 ` Martin Liška
  2019-07-22  9:36   ` Martin Liška
  0 siblings, 1 reply; 26+ messages in thread
From: Martin Liška @ 2019-05-14  9:11 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 179 bytes --]

On 5/6/19 4:00 PM, Martin Liška wrote:
> Hi.
> 
> I'm sending following backport that I've just tested.
> 
> Martin
> 

Hi.

There are 2 more patches that I've tested.

Martin

[-- Attachment #2: 0001-Backport-r271116.patch --]
[-- Type: text/x-patch, Size: 4910 bytes --]

From af452cc71498c097d09bc8ecd848d28555a00bb2 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 13 May 2019 07:04:58 +0000
Subject: [PATCH 1/2] Backport r271116

gcc/ChangeLog:

2019-05-13  Martin Liska  <mliska@suse.cz>

	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 c7c52ce3629..47c784a9388 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -604,27 +604,11 @@ bool function_info::group_line_p (unsigned n, unsigned src_idx)
 typedef vector<arc_info *> arc_vector_t;
 typedef vector<const block_info *> 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<loop_type> (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 &edges, int64_t &count)
 {
   /* Find the minimum edge of the cycle, and reduce all nodes in the cycle by
@@ -640,7 +624,7 @@ handle_cycle (const arc_vector_t &edges, int64_t &count)
   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
@@ -671,12 +655,12 @@ unblock (const block_info *u, block_vector_t &blocked,
    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 &path, block_info *start,
 	 block_vector_t &blocked, vector<block_vector_t> &block_lists,
 	 line_info &linfo, int64_t &count)
 {
-  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 ());
@@ -691,15 +675,19 @@ circuit (block_info *v, arc_vector_t &path, 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)
@@ -716,14 +704,13 @@ circuit (block_info *v, arc_vector_t &path, 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 &linfo, bool handle_negative_cycles = true)
+get_cycles_count (line_info &linfo)
 {
   /* Note that this algorithm works even if blocks aren't in sorted order.
      Each iteration of the circuit detection is completely independent
@@ -731,7 +718,7 @@ get_cycles_count (line_info &linfo, 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<block_info *>::iterator it = linfo.blocks.begin ();
        it != linfo.blocks.end (); it++)
@@ -739,14 +726,10 @@ get_cycles_count (line_info &linfo, bool handle_negative_cycles = true)
       arc_vector_t path;
       block_vector_t blocked;
       vector<block_vector_t > 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


[-- Attachment #3: 0002-Backport-r271117.patch --]
[-- Type: text/x-patch, Size: 2702 bytes --]

From 33a14c2ebe20dc58e986503fb00814e10dec9b1a Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 13 May 2019 07:05:23 +0000
Subject: [PATCH 2/2] Backport r271117

gcc/ChangeLog:

2019-05-13  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/90380
	* gcov.c (handle_cycle): Do not support zero cycle count,
	it should not be possible.
	(path_contains_zero_cycle_arc): New function.
	(circuit): Ignore zero cycle arc counts.
---
 gcc/gcov.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/gcc/gcov.c b/gcc/gcov.c
index 47c784a9388..a99802079dc 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -624,7 +624,7 @@ handle_cycle (const arc_vector_t &edges, int64_t &count)
   for (unsigned i = 0; i < edges.size (); i++)
     edges[i]->cs_count -= cycle_count;
 
-  gcc_assert (cycle_count >= 0);
+  gcc_assert (cycle_count > 0);
 }
 
 /* Unblock a block U from BLOCKED.  Apart from that, iterate all blocks
@@ -650,6 +650,17 @@ unblock (const block_info *u, block_vector_t &blocked,
     unblock (*it, blocked, block_lists);
 }
 
+/* Return true when PATH contains a zero cycle arc count.  */
+
+static bool
+path_contains_zero_cycle_arc (arc_vector_t &path)
+{
+  for (unsigned i = 0; i < path.size (); i++)
+    if (path[i]->cs_count == 0)
+      return true;
+  return false;
+}
+
 /* Find circuit going to block V, PATH is provisional seen cycle.
    BLOCKED is vector of blocked vertices, BLOCK_LISTS contains vertices
    blocked by a block.  COUNT is accumulated count of the current LINE.
@@ -670,7 +681,9 @@ circuit (block_info *v, arc_vector_t &path, block_info *start,
   for (arc_info *arc = v->succ; arc; arc = arc->succ_next)
     {
       block_info *w = arc->dst;
-      if (w < start || !linfo.has_block (w))
+      if (w < start
+	  || arc->cs_count == 0
+	  || !linfo.has_block (w))
 	continue;
 
       path.push_back (arc);
@@ -680,7 +693,8 @@ circuit (block_info *v, arc_vector_t &path, block_info *start,
 	  handle_cycle (path, count);
 	  loop_found = true;
 	}
-      else if (find (blocked.begin (), blocked.end (), w) == blocked.end ())
+      else if (!path_contains_zero_cycle_arc (path)
+	       &&  find (blocked.begin (), blocked.end (), w) == blocked.end ())
 	loop_found |= circuit (w, path, start, blocked, block_lists, linfo,
 			       count);
 
@@ -693,7 +707,9 @@ circuit (block_info *v, arc_vector_t &path, block_info *start,
     for (arc_info *arc = v->succ; arc; arc = arc->succ_next)
       {
 	block_info *w = arc->dst;
-	if (w < start || !linfo.has_block (w))
+	if (w < start
+	    || arc->cs_count == 0
+	    || !linfo.has_block (w))
 	  continue;
 
 	size_t index
-- 
2.21.0


^ permalink raw reply	[flat|nested] 26+ messages in thread

* GCC 8 backports
@ 2019-05-07 16:17 Marek Polacek
  0 siblings, 0 replies; 26+ messages in thread
From: Marek Polacek @ 2019-05-07 16:17 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 49 bytes --]

I'm backporting these 5 patches to gcc-8.

Marek

[-- Attachment #2: gcc8-pr88857.patch --]
[-- Type: text/plain, Size: 1021 bytes --]

2019-02-27  Marek Polacek  <polacek@redhat.com>

	PR c++/88857 - ICE with value-initialization of argument in template.
	* call.c (convert_like_real): Don't call build_value_init in template.

--- gcc/cp/call.c
+++ gcc/cp/call.c
@@ -7005,7 +7005,8 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
 	/* If we're initializing from {}, it's value-initialization.  */
 	if (BRACE_ENCLOSED_INITIALIZER_P (expr)
 	    && CONSTRUCTOR_NELTS (expr) == 0
-	    && TYPE_HAS_DEFAULT_CONSTRUCTOR (totype))
+	    && TYPE_HAS_DEFAULT_CONSTRUCTOR (totype)
+	    && !processing_template_decl)
 	  {
 	    bool direct = CONSTRUCTOR_IS_DIRECT_INIT (expr);
 	    if (abstract_virtuals_error_sfinae (NULL_TREE, totype, complain))
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp0x/initlist-value4.C
@@ -0,0 +1,12 @@
+// PR c++/88857
+// { dg-do compile { target c++11 } }
+
+class S { int a; };
+void foo (const S &, int);
+
+template <int N>
+void
+bar ()
+{
+  foo ({}); // { dg-error "too few arguments to function" }
+}

[-- Attachment #3: gcc8-pr89214.patch --]
[-- Type: text/plain, Size: 3417 bytes --]

2019-03-25  Marek Polacek  <polacek@redhat.com>
 
	PR c++/89214 - ICE when initializing aggregates with bases.
	* typeck2.c (digest_init_r): Warn about object slicing instead of
	crashing.

--- gcc/cp/typeck2.c
+++ gcc/cp/typeck2.c
@@ -1209,8 +1209,29 @@ digest_init_r (tree type, tree init, int nested, int flags,
     {
       tree elt = CONSTRUCTOR_ELT (stripped_init, 0)->value;
       if (reference_related_p (type, TREE_TYPE (elt)))
-	/* We should have fixed this in reshape_init.  */
-	gcc_unreachable ();
+	{
+	  /* In C++17, aggregates can have bases, thus participate in
+	     aggregate initialization.  In the following case:
+
+	       struct B { int c; };
+	       struct D : B { };
+	       D d{{D{{42}}}};
+
+	    there's an extra set of braces, so the D temporary initializes
+	    the first element of d, which is the B base subobject.  The base
+	    of type B is copy-initialized from the D temporary, causing
+	    object slicing.  */
+	  tree field = next_initializable_field (TYPE_FIELDS (type));
+	  if (field && DECL_FIELD_IS_BASE (field))
+	    {
+	      if (warning_at (loc, 0, "initializing a base class of type %qT "
+			      "results in object slicing", TREE_TYPE (field)))
+		inform (loc, "remove %<{ }%> around initializer");
+	    }
+	  else
+	    /* We should have fixed this in reshape_init.  */
+	    gcc_unreachable ();
+	}
     }
 
   if (BRACE_ENCLOSED_INITIALIZER_P (stripped_init)
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp1z/aggr-base8.C
@@ -0,0 +1,48 @@
+// PR c++/89214
+// { dg-do compile { target c++17 } }
+
+struct A
+{
+  A (int);
+};
+
+struct BB
+{
+  A a;
+};
+
+struct B : BB
+{
+};
+
+void
+foo ()
+{
+  B b1 = {42};
+  B b2 = {{42}};
+  B b3 = {{{42}}};
+
+  B b4 = B{42};
+  B b5 = B{{42}};
+  B b6 = B{{{42}}};
+
+  B b7 = {B{42}};
+  B b8 = {B{{42}}};
+  B b9 = {B{{{42}}}};
+
+  B b10 = {{B{42}}}; // { dg-warning "initializing a base class of type .BB. results in object slicing" }
+  B b11 = {{B{{42}}}}; // { dg-warning "initializing a base class of type .BB. results in object slicing" }
+  B b12 = {{B{{{42}}}}}; // { dg-warning "initializing a base class of type .BB. results in object slicing" }
+
+  B bb1{42};
+  B bb2{{42}};
+  B bb3{{{42}}};
+
+  B bb7{B{42}};
+  B bb8{B{{42}}};
+  B bb9{B{{{42}}}};
+
+  B bb10{{B{42}}}; // { dg-warning "initializing a base class of type .BB. results in object slicing" }
+  B bb11{{B{{42}}}}; // { dg-warning "initializing a base class of type .BB. results in object slicing" }
+  B bb12{{B{{{42}}}}}; // { dg-warning "initializing a base class of type .BB. results in object slicing" }
+}
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp1z/aggr-base9.C
@@ -0,0 +1,33 @@
+// PR c++/89214
+// { dg-do compile { target c++17 } }
+
+struct B {
+  int c;
+};
+
+struct D : B { };
+
+void
+foo ()
+{
+  D d1 = {42};
+  D d2 = {{42}};
+  
+  D d4 = D{42};
+  D d5 = D{{42}};
+ 
+  D d7 = {D{42}};
+  D d8 = {D{{42}}};
+
+  D d10 = {{D{42}}}; // { dg-warning "initializing a base class of type .B. results in object slicing" }
+  D d11 = {{D{{42}}}}; // { dg-warning "initializing a base class of type .B. results in object slicing" }
+
+  D dd1{42};
+  D dd2{{42}};
+  
+  D dd7{D{42}};
+  D dd8{D{{42}}};
+
+  D dd10{{D{42}}}; // { dg-warning "initializing a base class of type .B. results in object slicing" }
+  D dd11{{D{{42}}}}; // { dg-warning "initializing a base class of type .B. results in object slicing" }
+}

[-- Attachment #4: gcc8-pr89511.patch --]
[-- Type: text/plain, Size: 1142 bytes --]

2019-02-27  Marek Polacek  <polacek@redhat.com>

	PR c++/89511 - ICE with using-declaration and unscoped enumerator.
	* parser.c (cp_parser_using_declaration): For an unscoped enum
	only use its context if it's not a function declaration.

--- gcc/cp/parser.c
+++ gcc/cp/parser.c
@@ -19412,7 +19412,8 @@ cp_parser_using_declaration (cp_parser* parser,
 						  /*is_declaration=*/true);
   if (!qscope)
     qscope = global_namespace;
-  else if (UNSCOPED_ENUM_P (qscope))
+  else if (UNSCOPED_ENUM_P (qscope)
+	   && !TYPE_FUNCTION_SCOPE_P (qscope))
     qscope = CP_TYPE_CONTEXT (qscope);
 
   if (access_declaration_p && cp_parser_error_occurred (parser))
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp0x/using-enum-3.C
@@ -0,0 +1,21 @@
+// PR c++/89511
+// { dg-do compile { target c++11 } }
+
+void f ()
+{
+  enum e { a };
+  using e::a; // { dg-error "not a namespace or unscoped enum" }
+}
+
+struct S {
+  enum E { A };
+  using E::A; // { dg-error "type .S. is not a base type for type .S." }
+};
+
+namespace N {
+  enum E { B };
+}
+
+struct T {
+  using N::E::B; // { dg-error "using-declaration for non-member at class scope" }
+};

[-- Attachment #5: gcc8-pr89705.patch --]
[-- Type: text/plain, Size: 1501 bytes --]

2019-03-25  Marek Polacek  <polacek@redhat.com>

	PR c++/89705 - ICE with reference binding with conversion function.
	* call.c (reference_binding): If the result of the conversion function
	is a prvalue of non-class type, use the cv-unqualified type.

diff --git gcc/cp/call.c gcc/cp/call.c
index f16f2895402..c5ef07d0bee 100644
--- gcc/cp/call.c
+++ gcc/cp/call.c
@@ -1767,6 +1767,9 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags,
 	    && DECL_CONV_FN_P (t->cand->fn))
 	  {
 	    tree ftype = TREE_TYPE (TREE_TYPE (t->cand->fn));
+	    /* A prvalue of non-class type is cv-unqualified.  */
+	    if (TREE_CODE (ftype) != REFERENCE_TYPE && !CLASS_TYPE_P (ftype))
+	      ftype = cv_unqualified (ftype);
 	    int sflags = (flags|LOOKUP_NO_CONVERSION)&~LOOKUP_NO_TEMP_BIND;
 	    conversion *new_second
 	      = reference_binding (rto, ftype, NULL_TREE, c_cast_p,
diff --git gcc/testsuite/g++.dg/cpp0x/rv-conv2.C gcc/testsuite/g++.dg/cpp0x/rv-conv2.C
new file mode 100644
index 00000000000..9b9b154995b
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp0x/rv-conv2.C
@@ -0,0 +1,18 @@
+// PR c++/89705
+// { dg-do compile { target c++11 } }
+
+struct W { operator const volatile int(); };
+const int& rci = W();
+
+struct X { operator const int(); };
+int&& rri = X();
+
+struct Y { operator volatile int(); };
+int&& rri2 = Y();
+
+struct Z { operator const volatile int(); };
+volatile int&& rri3 = Z();
+
+enum E { A };
+struct S { operator const E(); };
+E&& rre = S();

[-- Attachment #6: gcc8-pr89876.patch --]
[-- Type: text/plain, Size: 851 bytes --]

2019-03-29  Marek Polacek  <polacek@redhat.com>

	PR c++/89876 - ICE with deprecated conversion.
	* call.c (convert_like_real): Only give warnings with tf_warning.

--- gcc/cp/call.c
+++ gcc/cp/call.c
@@ -7446,7 +7446,8 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
 
     case ck_qual:
       /* Warn about deprecated conversion if appropriate.  */
-      string_conv_p (totype, expr, 1);
+      if (complain & tf_warning)
+	string_conv_p (totype, expr, 1);
       break;
 
     case ck_ptr:
--- /dev/null
+++ gcc/testsuite/g++.dg/warn/conv5.C
@@ -0,0 +1,11 @@
+// PR c++/89876
+// { dg-do compile { target c++11 } }
+// { dg-prune-output "sorry" }
+
+template <typename T>
+T f (T, char*);
+
+template <typename T>
+decltype (f (T (), "")) g (T) { return ""; } // { dg-error "invalid conversion" }
+
+void h () { g (0); }

^ permalink raw reply	[flat|nested] 26+ messages in thread

* GCC 8 backports
@ 2019-05-06 14:00 Martin Liška
  2019-05-14  9:11 ` Martin Liška
  0 siblings, 1 reply; 26+ messages in thread
From: Martin Liška @ 2019-05-06 14:00 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 67 bytes --]

Hi.

I'm sending following backport that I've just tested.

Martin

[-- Attachment #2: 0001-Backport-r270899.patch --]
[-- Type: text/x-patch, Size: 3301 bytes --]

From ad56099403b078303477e3f501ef09b2e2b6e450 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 6 May 2019 07:35:59 +0000
Subject: [PATCH] Backport r270899

gcc/ChangeLog:

2019-05-06  Martin Liska  <mliska@suse.cz>

	PR sanitizer/90312
	* config/i386/i386-options.c (ix86_option_override_internal): Error only
	when -mabi is selected to a non-default version.

gcc/testsuite/ChangeLog:

2019-05-06  Martin Liska  <mliska@suse.cz>

	PR sanitizer/90312
	* gcc.dg/asan/pr87930.c: Run the test only on *linux or *gnu
	systems.
	* gcc.dg/tsan/pr88017.c: Likewise.
---
 gcc/config/i386/i386.c              | 17 +++++++++++------
 gcc/testsuite/gcc.dg/asan/pr87930.c |  2 +-
 gcc/testsuite/gcc.dg/tsan/pr88017.c |  2 +-
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 8a1ffd3769f..5b946e1a32f 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -3705,12 +3705,17 @@ ix86_option_override_internal (bool main_args_p,
     error ("%<-mabi=ms%> not supported with X32 ABI");
   gcc_assert (opts->x_ix86_abi == SYSV_ABI || opts->x_ix86_abi == MS_ABI);
 
-  if ((opts->x_flag_sanitize & SANITIZE_USER_ADDRESS) && opts->x_ix86_abi == MS_ABI)
-    error ("%<-mabi=ms%> not supported with %<-fsanitize=address%>");
-  if ((opts->x_flag_sanitize & SANITIZE_KERNEL_ADDRESS) && opts->x_ix86_abi == MS_ABI)
-    error ("%<-mabi=ms%> not supported with %<-fsanitize=kernel-address%>");
-  if ((opts->x_flag_sanitize & SANITIZE_THREAD) && opts->x_ix86_abi == MS_ABI)
-    error ("%<-mabi=ms%> not supported with %<-fsanitize=thread%>");
+  const char *abi_name = opts->x_ix86_abi == MS_ABI ? "ms" : "sysv";
+  if ((opts->x_flag_sanitize & SANITIZE_USER_ADDRESS)
+      && opts->x_ix86_abi != DEFAULT_ABI)
+    error ("%<-mabi=%s%> not supported with %<-fsanitize=address%>", abi_name);
+  if ((opts->x_flag_sanitize & SANITIZE_KERNEL_ADDRESS)
+      && opts->x_ix86_abi != DEFAULT_ABI)
+    error ("%<-mabi=%s%> not supported with %<-fsanitize=kernel-address%>",
+	   abi_name);
+  if ((opts->x_flag_sanitize & SANITIZE_THREAD)
+      && opts->x_ix86_abi != DEFAULT_ABI)
+    error ("%<-mabi=%s%> not supported with %<-fsanitize=thread%>", abi_name);
 
   /* For targets using ms ABI enable ms-extensions, if not
      explicit turned off.  For non-ms ABI we turn off this
diff --git a/gcc/testsuite/gcc.dg/asan/pr87930.c b/gcc/testsuite/gcc.dg/asan/pr87930.c
index 4f8e6999fde..5a65d3fb030 100644
--- a/gcc/testsuite/gcc.dg/asan/pr87930.c
+++ b/gcc/testsuite/gcc.dg/asan/pr87930.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && lp64 } } } */
+/* { dg-do compile { target { { i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } && lp64 } } } */
 /* { dg-options "-fsanitize=address -mabi=ms" } */
 
 int i;
diff --git a/gcc/testsuite/gcc.dg/tsan/pr88017.c b/gcc/testsuite/gcc.dg/tsan/pr88017.c
index 82693a67e87..10df2818b0d 100644
--- a/gcc/testsuite/gcc.dg/tsan/pr88017.c
+++ b/gcc/testsuite/gcc.dg/tsan/pr88017.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && lp64 } } } */
+/* { dg-do compile { target { { i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } && lp64 } } } */
 /* { dg-options "-fsanitize=thread -mabi=ms" } */
 
 int i;
-- 
2.21.0


^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2020-04-03 10:32 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-23  8:43 GCC 8 backports Martin Liška
2018-08-16 10:14 ` Martin Liška
2018-09-18  9:37   ` Martin Liška
2018-09-25  6:52     ` Martin Liška
2018-10-03 10:09       ` Martin Liška
2018-11-20 10:58         ` Martin Liška
2018-12-27 14:59           ` Martin Liška
2018-12-28 11:46             ` Sudakshina Das
2019-01-02 11:46               ` Martin Liška
2019-01-02 11:50                 ` Jan Hubicka
2019-01-03  8:46                   ` Martin Liška
2019-02-14 11:23           ` Martin Liška
2019-02-14 13:57             ` Martin Liška
2019-03-11  9:39               ` Martin Liška
2019-03-15  8:39                 ` Martin Liška
2019-03-28  8:53                   ` Martin Liška
2019-05-24  7:42                     ` Martin Liška
2019-07-04 10:17                       ` Martin Liška
2020-01-15 10:15 ` Martin Liška
2020-03-02  9:33 ` Martin Liška
2020-03-29 17:17 ` Martin Liška
2020-04-03 10:32   ` Martin Liška
2019-05-06 14:00 Martin Liška
2019-05-14  9:11 ` Martin Liška
2019-07-22  9:36   ` Martin Liška
2019-05-07 16:17 Marek Polacek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).