diff mbox series

GCC 8 backports

Message ID ba2054eb-5b7a-3c87-d498-5f462438fff7@suse.cz
State New
Headers show
Series GCC 8 backports | expand

Commit Message

Martin Liška May 23, 2018, 8:24 a.m. UTC
Hi.

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

Martin

Comments

Martin Liška Aug. 16, 2018, 10:14 a.m. UTC | #1
Hi.

Another 2 patches that I tested.

Martin
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
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
Martin Liška Sept. 18, 2018, 9:29 a.m. UTC | #2
Hi.

One more tested patch.

Martin
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);
     }
 }
Martin Liška Sept. 25, 2018, 6:48 a.m. UTC | #3
Hi.

One more tested patch.

Martin
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;
+}
Martin Liška Oct. 3, 2018, 9:23 a.m. UTC | #4
On 9/25/18 8:48 AM, Martin Liška wrote:
> Hi.
> 
> One more tested patch.
> 
> Martin
> 

One more tested patch.

Martin
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)\
Martin Liška Nov. 20, 2018, 10:58 a.m. UTC | #5
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
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;
+}
Martin Liška Dec. 27, 2018, 12:32 p.m. UTC | #6
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
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" } } */
Sudakshina Das Dec. 28, 2018, 11:24 a.m. UTC | #7
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
Martin Liška Jan. 2, 2019, 11:46 a.m. UTC | #8
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
Jan Hubicka Jan. 2, 2019, 11:50 a.m. UTC | #9
> 
> 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
Martin Liška Jan. 3, 2019, 8:46 a.m. UTC | #10
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
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" } } */
Martin Liška Feb. 14, 2019, 11:23 a.m. UTC | #11
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
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" } */
Martin Liška Feb. 14, 2019, 1:57 p.m. UTC | #12
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
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);
+    }
 }
Martin Liška March 11, 2019, 9:37 a.m. UTC | #13
Hi.

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

Martin
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);
Martin Liška March 15, 2019, 8:35 a.m. UTC | #14
Hi.

One more documentation patch.

Martin
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
Martin Liška March 28, 2019, 8:50 a.m. UTC | #15
Hi.

I'm backporting a documentation fix.

Martin
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
Martin Liška May 24, 2019, 7:42 a.m. UTC | #16
Hi.

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

Martin
Martin Liška July 4, 2019, 9:23 a.m. UTC | #17
I'm sending one more patch that I've tested.

Martin
Martin Liška Jan. 15, 2020, 9:47 a.m. UTC | #18
Hi.

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

Martin
Martin Liška March 2, 2020, 9:33 a.m. UTC | #19
Hi.

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

Martin
Martin Liška March 29, 2020, 5:17 p.m. UTC | #20
Hi.

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

Martin
Martin Liška April 3, 2020, 10:32 a.m. UTC | #21
Hi.

There's one more I've tested.

Martin
diff mbox series

Patch

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