SIL: replace SmallPtrSet<SILBasicBlock *> with BasicBlockSet in LinearLifetimeChecker

This makes it unnecessary to share a single instance of visited blocks across multiple calls the the checker.
This commit is contained in:
Erik Eckstein
2021-01-22 18:02:59 +01:00
parent c638a2f19f
commit ddd0f4d3a9
13 changed files with 46 additions and 80 deletions

View File

@@ -88,8 +88,7 @@ public:
SmallVector<Operand *, 8> endScopeUses;
transform(access->getEndAccesses(), std::back_inserter(endScopeUses),
[](EndAccessInst *eai) { return &eai->getAllOperands()[0]; });
SmallPtrSet<SILBasicBlock *, 4> visitedBlocks;
LinearLifetimeChecker checker(visitedBlocks, ctx.getDeadEndBlocks());
LinearLifetimeChecker checker(ctx.getDeadEndBlocks());
if (!checker.validateLifetime(access, endScopeUses,
liveRange.getAllConsumingUses())) {
// If we fail the linear lifetime check, then just recur:
@@ -137,9 +136,8 @@ public:
// Ok, we have some writes. See if any of them are within our live
// range. If any are, we definitely can not promote to load_borrow.
SmallPtrSet<SILBasicBlock *, 4> visitedBlocks;
SmallVector<BeginAccessInst *, 16> foundBeginAccess;
LinearLifetimeChecker checker(visitedBlocks, ctx.getDeadEndBlocks());
LinearLifetimeChecker checker(ctx.getDeadEndBlocks());
SILValue introducerValue = liveRange.getIntroducer().value;
if (!checker.usesNotContainedWithinLifetime(introducerValue,
liveRange.getDestroyingUses(),
@@ -161,7 +159,6 @@ public:
bai->getUsersOfType<EndAccessInst>(),
std::back_inserter(endAccessList),
[](EndAccessInst *eai) { return &eai->getAllOperands()[0]; });
visitedBlocks.clear();
// We know that our live range is based on a load [copy], so we know
// that our value must have a defining inst.
@@ -246,8 +243,7 @@ public:
value.visitLocalScopeEndingUses(
[&](Operand *use) { endScopeInsts.push_back(use); });
SmallPtrSet<SILBasicBlock *, 4> visitedBlocks;
LinearLifetimeChecker checker(visitedBlocks, ctx.getDeadEndBlocks());
LinearLifetimeChecker checker(ctx.getDeadEndBlocks());
// Returns true on success. So we invert.
bool foundError = !checker.validateLifetime(
@@ -292,8 +288,7 @@ public:
// Then make sure that all of our load [copy] uses are within the
// destroy_addr.
SmallPtrSet<SILBasicBlock *, 4> visitedBlocks;
LinearLifetimeChecker checker(visitedBlocks, ctx.getDeadEndBlocks());
LinearLifetimeChecker checker(ctx.getDeadEndBlocks());
// Returns true on success. So we invert.
bool foundError = !checker.validateLifetime(
stack, destroyAddrOperands /*consuming users*/,