Gentoo Archives: gentoo-commits

From: Sergei Trofimovich <slyfox@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gcc-patches:master commit in: 8.2.0/gentoo/
Date: Tue, 29 Jan 2019 20:24:53
Message-Id: 1548793384.1dfeaca5c52a5a266c7045622362a7c1da0eefc0.slyfox@gentoo
1 commit: 1dfeaca5c52a5a266c7045622362a7c1da0eefc0
2 Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
3 AuthorDate: Tue Jan 29 20:23:04 2019 +0000
4 Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
5 CommitDate: Tue Jan 29 20:23:04 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=1dfeaca5
7
8 8.2.0: backport ipa/devirt bad code generation, bug #676672
9
10 Reported-by: Thomas Deutschmann
11 Bug: https://bugs.gentoo.org/676672
12 Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>
13
14 8.2.0/gentoo/116_all_ipa-pgo-PR88561-fix.patch | 115 +++++++++++++++++++++++++
15 8.2.0/gentoo/README.history | 3 +
16 2 files changed, 118 insertions(+)
17
18 diff --git a/8.2.0/gentoo/116_all_ipa-pgo-PR88561-fix.patch b/8.2.0/gentoo/116_all_ipa-pgo-PR88561-fix.patch
19 new file mode 100644
20 index 0000000..5cc4cc0
21 --- /dev/null
22 +++ b/8.2.0/gentoo/116_all_ipa-pgo-PR88561-fix.patch
23 @@ -0,0 +1,115 @@
24 +https://gcc.gnu.org/PR88561
25 +https://bugs.gentoo.org/676672
26 +
27 +From 497651ff19a85affaf1273b827db6920384af77d Mon Sep 17 00:00:00 2001
28 +From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
29 +Date: Thu, 27 Dec 2018 12:33:00 +0000
30 +Subject: [PATCH] Backport r267338
31 +
32 +2018-12-27 Martin Liska <mliska@××××.cz>
33 +
34 + Backport from mainline
35 + 2018-12-15 Jan Hubicka <hubicka@×××.cz>
36 +
37 + PR ipa/88561
38 + * ipa-polymorphic-call.c
39 + (ipa_polymorphic_call_context::ipa_polymorphic_call_context): Handle
40 + arguments of thunks correctly.
41 + (ipa_polymorphic_call_context::get_dynamic_context): Be ready for
42 + NULL instance pinter.
43 + * lto-cgraph.c (lto_output_node): Always stream thunk info.
44 +
45 +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-8-branch@267433 138bc75d-0d04-0410-961f-82ee72b054a4
46 +---
47 + gcc/ipa-polymorphic-call.c | 32 +++++-
48 + gcc/lto-cgraph.c | 8 +-
49 +
50 +--- a/gcc/ipa-polymorphic-call.c
51 ++++ b/gcc/ipa-polymorphic-call.c
52 +@@ -995,9 +995,22 @@ ipa_polymorphic_call_context::ipa_polymorphic_call_context (tree fndecl,
53 + {
54 + outer_type
55 + = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (base_pointer)));
56 ++ cgraph_node *node = cgraph_node::get (current_function_decl);
57 + gcc_assert (TREE_CODE (outer_type) == RECORD_TYPE
58 + || TREE_CODE (outer_type) == UNION_TYPE);
59 +
60 ++ /* Handle the case we inlined into a thunk. In this case
61 ++ thunk has THIS pointer of type bar, but it really receives
62 ++ address to its base type foo which sits in bar at
63 ++ 0-thunk.fixed_offset. It starts with code that adds
64 ++ think.fixed_offset to the pointer to compensate for this.
65 ++
66 ++ Because we walked all the way to the begining of thunk, we now
67 ++ see pointer &bar-thunk.fixed_offset and need to compensate
68 ++ for it. */
69 ++ if (node->thunk.fixed_offset)
70 ++ offset -= node->thunk.fixed_offset * BITS_PER_UNIT;
71 ++
72 + /* Dynamic casting has possibly upcasted the type
73 + in the hiearchy. In this case outer type is less
74 + informative than inner type and we should forget
75 +@@ -1005,7 +1018,11 @@ ipa_polymorphic_call_context::ipa_polymorphic_call_context (tree fndecl,
76 + if ((otr_type
77 + && !contains_type_p (outer_type, offset,
78 + otr_type))
79 +- || !contains_polymorphic_type_p (outer_type))
80 ++ || !contains_polymorphic_type_p (outer_type)
81 ++ /* If we compile thunk with virtual offset, the THIS pointer
82 ++ is adjusted by unknown value. We can't thus use outer info
83 ++ at all. */
84 ++ || node->thunk.virtual_offset_p)
85 + {
86 + outer_type = NULL;
87 + if (instance)
88 +@@ -1030,7 +1047,15 @@ ipa_polymorphic_call_context::ipa_polymorphic_call_context (tree fndecl,
89 + maybe_in_construction = false;
90 + }
91 + if (instance)
92 +- *instance = base_pointer;
93 ++ {
94 ++ /* If method is expanded thunk, we need to apply thunk offset
95 ++ to instance pointer. */
96 ++ if (node->thunk.virtual_offset_p
97 ++ || node->thunk.fixed_offset)
98 ++ *instance = NULL;
99 ++ else
100 ++ *instance = base_pointer;
101 ++ }
102 + return;
103 + }
104 + /* Non-PODs passed by value are really passed by invisible
105 +@@ -1547,6 +1572,9 @@ ipa_polymorphic_call_context::get_dynamic_type (tree instance,
106 + HOST_WIDE_INT instance_offset = offset;
107 + tree instance_outer_type = outer_type;
108 +
109 ++ if (!instance)
110 ++ return false;
111 ++
112 + if (otr_type)
113 + otr_type = TYPE_MAIN_VARIANT (otr_type);
114 +
115 +--- a/gcc/lto-cgraph.c
116 ++++ b/gcc/lto-cgraph.c
117 +@@ -546,7 +546,11 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node,
118 + streamer_write_bitpack (&bp);
119 + streamer_write_data_stream (ob->main_stream, section, strlen (section) + 1);
120 +
121 +- if (node->thunk.thunk_p)
122 ++ /* Stream thunk info always because we use it in
123 ++ ipa_polymorphic_call_context::ipa_polymorphic_call_context
124 ++ to properly interpret THIS pointers for thunks that has been converted
125 ++ to Gimple. */
126 ++ if (node->definition)
127 + {
128 + streamer_write_uhwi_stream
129 + (ob->main_stream,
130 +@@ -1317,7 +1321,7 @@ input_node (struct lto_file_decl_data *file_data,
131 + if (section)
132 + node->set_section_for_node (section);
133 +
134 +- if (node->thunk.thunk_p)
135 ++ if (node->definition)
136 + {
137 + int type = streamer_read_uhwi (ib);
138 + HOST_WIDE_INT fixed_offset = streamer_read_uhwi (ib);
139
140 diff --git a/8.2.0/gentoo/README.history b/8.2.0/gentoo/README.history
141 index 80fef3b..a20d870 100644
142 --- a/8.2.0/gentoo/README.history
143 +++ b/8.2.0/gentoo/README.history
144 @@ -1,3 +1,6 @@
145 +1.8 TODO
146 + + 116_all_ipa-pgo-PR88561-fix.patch
147 +
148 1.7 26 Dec 2018
149 + 114_all_kr-decl-PR88214.patch
150 + 115_all_avx2-SIGSEGV-PR86871.patch