@@ -196,12 +196,10 @@ class PrunedLiveBlocks {
196
196
197
197
unsigned size () const { return bits.size () / 2 ; }
198
198
199
- // FIXME: specialize this for scalar liveness, which is the critical path
200
- // for all OSSA utilities.
201
199
IsLive getLiveness (unsigned bitNo) const {
202
- SmallVector<IsLive, 1 > foundLiveness;
203
- getLiveness (bitNo, bitNo + 1 , foundLiveness) ;
204
- return foundLiveness[ 0 ] ;
200
+ if (!bits[bitNo * 2 ])
201
+ return IsLive::Dead ;
202
+ return bits[bitNo * 2 + 1 ] ? LiveOut : LiveWithin ;
205
203
}
206
204
207
205
void getLiveness (unsigned startBitNo, unsigned endBitNo,
@@ -281,9 +279,12 @@ class PrunedLiveBlocks {
281
279
282
280
// / Update this liveness result for a single use.
283
281
IsLive updateForUse (SILInstruction *user, unsigned bitNo) {
284
- SmallVector<IsLive, 1 > resultingLiveness;
285
- updateForUse (user, bitNo, bitNo + 1 , resultingLiveness);
286
- return resultingLiveness[0 ];
282
+ auto *block = user->getParent ();
283
+ auto liveness = getBlockLiveness (block, bitNo);
284
+ if (liveness != Dead)
285
+ return liveness;
286
+ computeUseBlockLiveness (block, bitNo, bitNo + 1 );
287
+ return getBlockLiveness (block, bitNo);
287
288
}
288
289
289
290
// / Update this range of liveness results for a single use.
@@ -292,9 +293,12 @@ class PrunedLiveBlocks {
292
293
SmallVectorImpl<IsLive> &resultingLiveness);
293
294
294
295
IsLive getBlockLiveness (SILBasicBlock *bb, unsigned bitNo) const {
295
- SmallVector<IsLive, 1 > isLive;
296
- getBlockLiveness (bb, bitNo, bitNo + 1 , isLive);
297
- return isLive[0 ];
296
+ auto liveBlockIter = liveBlocks.find (bb);
297
+ if (liveBlockIter == liveBlocks.end ()) {
298
+ return Dead;
299
+ }
300
+
301
+ return liveBlockIter->second .getLiveness (bitNo);
298
302
}
299
303
300
304
// FIXME: This API should directly return the live bitset. The live bitset
0 commit comments