File tree 1 file changed +12
-0
lines changed 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -221,10 +221,15 @@ static void shareBuffers(Module &M) {
221
221
liveBuffers.insert (W);
222
222
}
223
223
224
+ // Output buffers of the current instruction.
225
+ std::unordered_set<Value *> outBuffers;
226
+
224
227
// For each instruction, in reverse order.
225
228
for (auto it = instrs.rbegin (), e = instrs.rend (); it != e; ++it) {
226
229
Instruction *I = *it;
227
230
231
+ outBuffers.clear ();
232
+
228
233
// Remove <out> dependencies from the live set, because this instruction
229
234
// writes into them. This means that the buffer is unused before the write
230
235
// point.
@@ -241,6 +246,7 @@ static void shareBuffers(Module &M) {
241
246
auto it = liveBuffers.find (ai);
242
247
if (it != liveBuffers.end ()) {
243
248
liveBuffers.erase (it);
249
+ outBuffers.insert (ai);
244
250
}
245
251
continue ;
246
252
}
@@ -249,6 +255,12 @@ static void shareBuffers(Module &M) {
249
255
if (ai && O.second == OperandKind::InOut) {
250
256
liveBuffers.insert (ai);
251
257
}
258
+ // The <In> use of a buffer that is also used as an <Out> means that the
259
+ // value of the buffer is being consumed, which means that it is alive.
260
+ // Add to the live set.
261
+ if (ai && O.second == OperandKind::In && outBuffers.count (ai) > 0 ) {
262
+ liveBuffers.insert (ai);
263
+ }
252
264
}
253
265
254
266
// Now that we've calculated the liveness for the exact location of the
You can’t perform that action at this time.
0 commit comments