1 |
commit: 7bf989ed8b53a13de6a6551b7f346b1dcadf5966 |
2 |
Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Oct 2 09:12:10 2020 +0000 |
4 |
Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Oct 2 09:12:10 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=7bf989ed |
7 |
|
8 |
10.2.0: fix multiple speculation resolution on prog builds |
9 |
|
10 |
Reported-by: Ștefan Talpalaru |
11 |
Bug: https://gcc.gnu.org/PR96394 |
12 |
Bug: https://bugs.gentoo.org/734006 |
13 |
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org> |
14 |
|
15 |
10.2.0/gentoo/39_all_ipa-prop-multispec.patch | 150 ++++++++++++++++++++++++++ |
16 |
10.2.0/gentoo/README.history | 1 + |
17 |
2 files changed, 151 insertions(+) |
18 |
|
19 |
diff --git a/10.2.0/gentoo/39_all_ipa-prop-multispec.patch b/10.2.0/gentoo/39_all_ipa-prop-multispec.patch |
20 |
new file mode 100644 |
21 |
index 0000000..6e19992 |
22 |
--- /dev/null |
23 |
+++ b/10.2.0/gentoo/39_all_ipa-prop-multispec.patch |
24 |
@@ -0,0 +1,150 @@ |
25 |
+https://gcc.gnu.org/PR96394 |
26 |
+https://bugs.gentoo.org/734006 |
27 |
+ |
28 |
+From 7f790f414ec38581b9bb033ab64e4ad12b9f8a4c Mon Sep 17 00:00:00 2001 |
29 |
+From: Martin Jambor <mjambor@××××.cz> |
30 |
+Date: Thu, 1 Oct 2020 19:39:27 +0200 |
31 |
+Subject: [PATCH] ipa-prop: Fix multiple-target speculation resolution |
32 |
+ |
33 |
+Hi, |
34 |
+ |
35 |
+as the FIXME which this patch removes states, the current code does |
36 |
+not work when a call with multiple speculative targets gets resolved |
37 |
+through parameter tracking during inlining - it feeds the inliner an |
38 |
+edge it has already dealt with. The patch makes the code which should |
39 |
+prevent it aware of the possibility that that speculation can have |
40 |
+more than one target now. |
41 |
+ |
42 |
+Bootstrapped and tested and LTO bootstrapped on x86_64-linux. I did not |
43 |
+try profiled LTO bootstrap because it fails even without the patch (even |
44 |
+without Ada, just C, C++ and Fortran, at least commit 92f0d3d03a7 does). |
45 |
+OK for trunk? |
46 |
+ |
47 |
+Thanks, |
48 |
+ |
49 |
+Martin |
50 |
+ |
51 |
+gcc/ChangeLog: |
52 |
+ |
53 |
+2020-09-30 Martin Jambor <mjambor@××××.cz> |
54 |
+ |
55 |
+ PR ipa/96394 |
56 |
+ * ipa-prop.c (update_indirect_edges_after_inlining): Do not add |
57 |
+ resolved speculation edges to vector of new direct edges even in |
58 |
+ presence of multiple speculative direct edges for a single call. |
59 |
+ |
60 |
+gcc/testsuite/ChangeLog: |
61 |
+ |
62 |
+2020-09-30 Martin Jambor <mjambor@××××.cz> |
63 |
+ |
64 |
+ PR ipa/96394 |
65 |
+ * gcc.dg/tree-prof/pr96394.c: New test. |
66 |
+--- |
67 |
+ gcc/ipa-prop.c | 10 ++-- |
68 |
+ gcc/testsuite/gcc.dg/tree-prof/pr96394.c | 64 ++++++++++++++++++++++++ |
69 |
+ 2 files changed, 70 insertions(+), 4 deletions(-) |
70 |
+ create mode 100644 gcc/testsuite/gcc.dg/tree-prof/pr96394.c |
71 |
+ |
72 |
+diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c |
73 |
+index ea88fd3fd95..0ff04d344e1 100644 |
74 |
+--- a/gcc/ipa-prop.c |
75 |
++++ b/gcc/ipa-prop.c |
76 |
+@@ -3787,11 +3787,13 @@ update_indirect_edges_after_inlining (struct cgraph_edge *cs, |
77 |
+ |
78 |
+ param_index = ici->param_index; |
79 |
+ jfunc = ipa_get_ith_jump_func (top, param_index); |
80 |
+- cgraph_node *spec_target = NULL; |
81 |
+ |
82 |
+- /* FIXME: This may need updating for multiple calls. */ |
83 |
++ auto_vec<cgraph_node *, 4> spec_targets; |
84 |
+ if (ie->speculative) |
85 |
+- spec_target = ie->first_speculative_call_target ()->callee; |
86 |
++ for (cgraph_edge *direct = ie->first_speculative_call_target (); |
87 |
++ direct; |
88 |
++ direct = direct->next_speculative_call_target ()) |
89 |
++ spec_targets.safe_push (direct->callee); |
90 |
+ |
91 |
+ if (!opt_for_fn (node->decl, flag_indirect_inlining)) |
92 |
+ new_direct_edge = NULL; |
93 |
+@@ -3814,7 +3816,7 @@ update_indirect_edges_after_inlining (struct cgraph_edge *cs, |
94 |
+ |
95 |
+ /* If speculation was removed, then we need to do nothing. */ |
96 |
+ if (new_direct_edge && new_direct_edge != ie |
97 |
+- && new_direct_edge->callee == spec_target) |
98 |
++ && spec_targets.contains (new_direct_edge->callee)) |
99 |
+ { |
100 |
+ new_direct_edge->indirect_inlining_edge = 1; |
101 |
+ top = IPA_EDGE_REF (cs); |
102 |
+diff --git a/gcc/testsuite/gcc.dg/tree-prof/pr96394.c b/gcc/testsuite/gcc.dg/tree-prof/pr96394.c |
103 |
+new file mode 100644 |
104 |
+index 00000000000..4280182a7c3 |
105 |
+--- /dev/null |
106 |
++++ b/gcc/testsuite/gcc.dg/tree-prof/pr96394.c |
107 |
+@@ -0,0 +1,64 @@ |
108 |
++/* PR ipa/96394 */ |
109 |
++/* { dg-options "-O2" } */ |
110 |
++ |
111 |
++typedef struct _entry { |
112 |
++ int has_next; |
113 |
++ int next_ix; |
114 |
++ int count; |
115 |
++} entry; |
116 |
++ |
117 |
++extern entry table[]; |
118 |
++ |
119 |
++void * |
120 |
++__attribute__((noipa)) |
121 |
++PyErr_Format(entry * e){ return 0; } |
122 |
++ |
123 |
++void ae(entry *); |
124 |
++int h(entry *); |
125 |
++int ap(entry *); |
126 |
++int ag(entry *); |
127 |
++ |
128 |
++int ag(entry *j) { |
129 |
++ if (j->has_next) |
130 |
++ h(&table[j->next_ix]); |
131 |
++ return 0; |
132 |
++} |
133 |
++static int ai(entry *j, int k(entry *), int l, int m) { |
134 |
++ int am = 1; |
135 |
++ int ab; |
136 |
++ |
137 |
++ /* k is either 'h' or 'ap': 50%/50% */ |
138 |
++ ab = k(j); |
139 |
++ |
140 |
++ /* loop never gets executed on real data */ |
141 |
++ for (; j->count >= 2; am += 2) |
142 |
++ if (l) { |
143 |
++ entry *i = &table[am + m]; |
144 |
++ PyErr_Format(i); |
145 |
++ } |
146 |
++ return ab; |
147 |
++} |
148 |
++void |
149 |
++__attribute__((noipa)) |
150 |
++bug() { |
151 |
++ h(table); |
152 |
++ h(table); |
153 |
++} |
154 |
++int h(entry *j) { return ai(j, ap, 4, 5); } |
155 |
++int ap(entry *j) { return ai(j, ag, 14, 4); } |
156 |
++ |
157 |
++int main(void) |
158 |
++{ |
159 |
++ bug(); |
160 |
++} |
161 |
++ |
162 |
++entry table[2] = { |
163 |
++ { .has_next = 1 |
164 |
++ , .next_ix = 1 |
165 |
++ , .count = 0 |
166 |
++ }, |
167 |
++ { .has_next = 0 |
168 |
++ , .next_ix = 0 |
169 |
++ , .count = 0 |
170 |
++ }, |
171 |
++}; |
172 |
+-- |
173 |
+2.28.0 |
174 |
+ |
175 |
|
176 |
diff --git a/10.2.0/gentoo/README.history b/10.2.0/gentoo/README.history |
177 |
index 6d00c5a..5929aae 100644 |
178 |
--- a/10.2.0/gentoo/README.history |
179 |
+++ b/10.2.0/gentoo/README.history |
180 |
@@ -2,6 +2,7 @@ |
181 |
U 28_all_EXTRA_OPTIONS-fstack-clash-protection.patch |
182 |
+ 37_all_c-vector-init-PR96377.patch |
183 |
+ 38_all_gcov-TOPN-PR96913.patch |
184 |
+ + 39_all_ipa-prop-multispec.patch |
185 |
|
186 |
2 23 Aug 2020 |
187 |
+ 33_all_lto-O0-mix-ICE-ipa-PR96291.patch |