@@ -202,6 +202,8 @@ class PrunedLiveBlocks {
202
202
return bits[bitNo * 2 + 1 ] ? LiveOut : LiveWithin;
203
203
}
204
204
205
+ // / Returns the liveness in \p resultingFoundLiveness. We only return the
206
+ // / bits for endBitNo - startBitNo.
205
207
void getLiveness (unsigned startBitNo, unsigned endBitNo,
206
208
SmallVectorImpl<IsLive> &resultingFoundLiveness) const {
207
209
unsigned actualStartBitNo = startBitNo * 2 ;
@@ -301,8 +303,8 @@ class PrunedLiveBlocks {
301
303
return liveBlockIter->second .getLiveness (bitNo);
302
304
}
303
305
304
- // FIXME: This API should directly return the live bitset. The live bitset
305
- // type should have an api for querying and iterating over the live fields.
306
+ // / FIXME: This API should directly return the live bitset. The live bitset
307
+ // / type should have an api for querying and iterating over the live fields.
306
308
void getBlockLiveness (SILBasicBlock *bb, unsigned startBitNo,
307
309
unsigned endBitNo,
308
310
SmallVectorImpl<IsLive> &foundLivenessInfo) const {
@@ -324,11 +326,6 @@ class PrunedLiveBlocks {
324
326
325
327
protected:
326
328
void markBlockLive (SILBasicBlock *bb, unsigned bitNo, IsLive isLive) {
327
- markBlockLive (bb, bitNo, bitNo + 1 , isLive);
328
- }
329
-
330
- void markBlockLive (SILBasicBlock *bb, unsigned startBitNo, unsigned endBitNo,
331
- IsLive isLive) {
332
329
assert (isLive != Dead && " erasing live blocks isn't implemented." );
333
330
auto iterAndInserted =
334
331
liveBlocks.insert (std::make_pair (bb, LivenessSmallBitVector ()));
@@ -338,13 +335,33 @@ class PrunedLiveBlocks {
338
335
// we have more than SmallBitVector's small size number of bits.
339
336
auto &insertedBV = iterAndInserted.first ->getSecond ();
340
337
insertedBV.init (numBitsToTrack);
341
- insertedBV.setLiveness (startBitNo, endBitNo , isLive);
338
+ insertedBV.setLiveness (bitNo, bitNo + 1 , isLive);
342
339
if (discoveredBlocks)
343
340
discoveredBlocks->push_back (bb);
344
- } else if (isLive == LiveOut) {
345
- // Update the existing entry to be live-out.
346
- iterAndInserted.first ->getSecond ().setLiveness (startBitNo, endBitNo,
347
- LiveOut);
341
+ } else {
342
+ // If we are dead, always update to the new liveness.
343
+ switch (iterAndInserted.first ->getSecond ().getLiveness (bitNo)) {
344
+ case Dead:
345
+ iterAndInserted.first ->getSecond ().setLiveness (bitNo, bitNo + 1 ,
346
+ isLive);
347
+ break ;
348
+ case LiveWithin:
349
+ if (isLive == LiveOut) {
350
+ // Update the existing entry to be live-out.
351
+ iterAndInserted.first ->getSecond ().setLiveness (bitNo, bitNo + 1 ,
352
+ LiveOut);
353
+ }
354
+ break ;
355
+ case LiveOut:
356
+ break ;
357
+ }
358
+ }
359
+ }
360
+
361
+ void markBlockLive (SILBasicBlock *bb, unsigned startBitNo, unsigned endBitNo,
362
+ IsLive isLive) {
363
+ for (unsigned index : range (startBitNo, endBitNo)) {
364
+ markBlockLive (bb, index, isLive);
348
365
}
349
366
}
350
367
0 commit comments