@@ -1221,17 +1221,24 @@ class FieldSensitiveSSAPrunedLiveRange
1221
1221
return inst == defInst.first && defInst.second ->contains (bit);
1222
1222
}
1223
1223
1224
- bool isDef (SILInstruction *inst, SmallBitVector const &bits) const {
1224
+ void isDef (SILInstruction *inst, SmallBitVector const &bits,
1225
+ SmallBitVector &bitsOut) const {
1226
+ assert (bitsOut.none ());
1225
1227
if (inst != defInst.first )
1226
- return false ;
1227
- SmallBitVector defBits (bits.size ());
1228
- defInst.second ->setBits (defBits);
1229
- return (defBits & bits) == bits;
1228
+ return ;
1229
+ defInst.second ->setBits (bitsOut);
1230
+ bitsOut &= bits;
1230
1231
}
1231
1232
1232
- bool isDef (SILInstruction *inst, TypeTreeLeafTypeRange span) const {
1233
- return inst == defInst.first &&
1234
- defInst.second ->setIntersection (span).has_value ();
1233
+ void isDef (SILInstruction *inst, TypeTreeLeafTypeRange span,
1234
+ SmallBitVector &bitsOut) const {
1235
+ assert (bitsOut.none ());
1236
+ if (inst != defInst.first )
1237
+ return ;
1238
+ auto intersection = defInst.second ->setIntersection (span);
1239
+ if (!intersection.has_value ())
1240
+ return ;
1241
+ intersection.value ().setBits (bitsOut);
1235
1242
}
1236
1243
1237
1244
bool isDefBlock (SILBasicBlock *block, unsigned bit) const {
@@ -1294,20 +1301,16 @@ class FieldSensitiveMultiDefPrunedLiveRange
1294
1301
bits, [&](auto range) { initializeDef (def, range); });
1295
1302
}
1296
1303
1297
- void initializeDef (SILValue def , TypeTreeLeafTypeRange span) {
1304
+ void initializeDef (SILNode *node , TypeTreeLeafTypeRange span) {
1298
1305
assert (Super::isInitialized ());
1299
- defs.insert (def , span);
1300
- auto *block = def ->getParentBlock ();
1306
+ defs.insert (node , span);
1307
+ auto *block = node ->getParentBlock ();
1301
1308
defBlocks.insert (block, span);
1302
1309
initializeDefBlock (block, span);
1303
1310
}
1304
1311
1305
1312
void initializeDef (SILInstruction *def, TypeTreeLeafTypeRange span) {
1306
- assert (Super::isInitialized ());
1307
- defs.insert (cast<SILNode>(def), span);
1308
- auto *block = def->getParent ();
1309
- defBlocks.insert (block, span);
1310
- initializeDefBlock (block, span);
1313
+ initializeDef (cast<SILNode>(def), span);
1311
1314
}
1312
1315
1313
1316
bool isInitialized () const { return Super::isInitialized () && !defs.empty (); }
@@ -1322,24 +1325,32 @@ class FieldSensitiveMultiDefPrunedLiveRange
1322
1325
*iter, [&](TypeTreeLeafTypeRange span) { return span.contains (bit); });
1323
1326
}
1324
1327
1325
- bool isDefBlock (SILBasicBlock *block, TypeTreeLeafTypeRange span) const {
1328
+ void isDefBlock (SILBasicBlock *block, TypeTreeLeafTypeRange span,
1329
+ SmallBitVector &bitsOut) const {
1326
1330
assert (isInitialized ());
1331
+ assert (bitsOut.none ());
1327
1332
auto iter = defBlocks.find (block);
1328
1333
if (!iter)
1329
- return false ;
1330
- return llvm::any_of (*iter, [&](TypeTreeLeafTypeRange storedSpan) {
1331
- return span.setIntersection (storedSpan).has_value ();
1332
- });
1334
+ return ;
1335
+ for (auto defSpan : *iter) {
1336
+ auto intersection = span.setIntersection (defSpan);
1337
+ if (!intersection.has_value ())
1338
+ continue ;
1339
+ intersection.value ().setBits (bitsOut);
1340
+ }
1333
1341
}
1334
1342
1335
- bool isDefBlock (SILBasicBlock *block, SmallBitVector const &bits) const {
1343
+ void isDefBlock (SILBasicBlock *block, SmallBitVector const &bits,
1344
+ SmallBitVector &bitsOut) const {
1336
1345
assert (isInitialized ());
1346
+ assert (bitsOut.none ());
1337
1347
auto iter = defBlocks.find (block);
1338
1348
if (!iter)
1339
- return false ;
1340
- return llvm::any_of (*iter, [&](TypeTreeLeafTypeRange storedSpan) {
1341
- return storedSpan.intersects (bits);
1342
- });
1349
+ return ;
1350
+ for (auto defSpan : *iter) {
1351
+ defSpan.setBits (bitsOut);
1352
+ }
1353
+ bitsOut &= bits;
1343
1354
}
1344
1355
1345
1356
// / Return true if \p user occurs before the first def in the same basic
@@ -1362,66 +1373,69 @@ class FieldSensitiveMultiDefPrunedLiveRange
1362
1373
}
1363
1374
}
1364
1375
1365
- bool isDef (SILInstruction *inst , unsigned bit) const {
1376
+ bool isDef (SILNode *node , unsigned bit) const {
1366
1377
assert (isInitialized ());
1367
- auto iter = defs.find (cast<SILNode>(inst) );
1378
+ auto iter = defs.find (node );
1368
1379
if (!iter)
1369
1380
return false ;
1370
1381
return llvm::any_of (
1371
1382
*iter, [&](TypeTreeLeafTypeRange span) { return span.contains (bit); });
1372
1383
}
1373
1384
1385
+ bool isDef (SILInstruction *inst, unsigned bit) const {
1386
+ return isDef (cast<SILNode>(inst), bit);
1387
+ }
1388
+
1374
1389
bool isDef (SILValue value, unsigned bit) const {
1375
- assert (isInitialized ());
1376
- auto iter = defs.find (cast<SILNode>(value));
1377
- if (!iter)
1378
- return false ;
1379
- return llvm::any_of (
1380
- *iter, [&](TypeTreeLeafTypeRange span) { return span.contains (bit); });
1390
+ return isDef (cast<SILNode>(value), bit);
1381
1391
}
1382
1392
1383
- bool isDef (SILValue value, SmallBitVector const &bits) const {
1393
+ void isDef (SILNode *node, SmallBitVector const &bits,
1394
+ SmallBitVector &bitsOut) const {
1384
1395
assert (isInitialized ());
1385
- auto iter = defs.find (cast<SILNode>(value));
1396
+ assert (bitsOut.none ());
1397
+ auto iter = defs.find (node);
1386
1398
if (!iter)
1387
- return false ;
1388
- SmallBitVector allBits (bits.size ());
1399
+ return ;
1389
1400
for (auto range : *iter) {
1390
- range.setBits (allBits );
1401
+ range.setBits (bitsOut );
1391
1402
}
1392
- return (bits & allBits) == bits;
1403
+ bitsOut &= bits;
1404
+ }
1405
+
1406
+ void isDef (SILValue value, SmallBitVector const &bits,
1407
+ SmallBitVector &bitsOut) const {
1408
+ isDef (cast<SILNode>(value), bits, bitsOut);
1409
+ }
1410
+
1411
+ void isDef (SILInstruction *inst, SmallBitVector const &bits,
1412
+ SmallBitVector &bitsOut) const {
1413
+ isDef (cast<SILNode>(inst), bits, bitsOut);
1393
1414
}
1394
1415
1395
- bool isDef (SILInstruction *inst, SmallBitVector const &bits) const {
1416
+ void isDef (SILNode *node, TypeTreeLeafTypeRange span,
1417
+ SmallBitVector &bitsOut) const {
1396
1418
assert (isInitialized ());
1397
- auto iter = defs.find (cast<SILNode>(inst));
1419
+ assert (bitsOut.none ());
1420
+ auto iter = defs.find (node);
1398
1421
if (!iter)
1399
- return false ;
1400
- SmallBitVector allBits (bits.size ());
1401
- for (auto range : *iter) {
1402
- range.setBits (allBits);
1422
+ return ;
1423
+ for (auto defSpan : *iter) {
1424
+ auto intersection = span.setIntersection (defSpan);
1425
+ if (!intersection.has_value ())
1426
+ continue ;
1427
+ span.setBits (bitsOut);
1403
1428
}
1404
- return (bits & allBits) == bits;
1405
1429
}
1406
1430
1407
- bool isDef (SILInstruction *inst, TypeTreeLeafTypeRange span) const {
1408
- assert (isInitialized ());
1409
- auto iter = defs.find (cast<SILNode>(inst));
1410
- if (!iter)
1411
- return false ;
1412
- return llvm::any_of (*iter, [&](TypeTreeLeafTypeRange storedSpan) {
1413
- return span.setIntersection (storedSpan).has_value ();
1414
- });
1431
+ void isDef (SILInstruction *inst, TypeTreeLeafTypeRange span,
1432
+ SmallBitVector &bitsOut) const {
1433
+ return isDef (cast<SILNode>(inst), span, bitsOut);
1415
1434
}
1416
1435
1417
- bool isDef (SILValue value, TypeTreeLeafTypeRange span) const {
1418
- assert (isInitialized ());
1419
- auto iter = defs.find (cast<SILNode>(value));
1420
- if (!iter)
1421
- return false ;
1422
- return llvm::any_of (*iter, [&](TypeTreeLeafTypeRange storedSpan) {
1423
- return span.setIntersection (storedSpan).has_value ();
1424
- });
1436
+ void isDef (SILValue value, TypeTreeLeafTypeRange span,
1437
+ SmallBitVector &bitsOut) const {
1438
+ return isDef (cast<SILNode>(value), span, bitsOut);
1425
1439
}
1426
1440
1427
1441
void
0 commit comments