Skip to content

Commit f15435d

Browse files
authored
Merge pull request #29872 from gottesmm/pr-fb98c866323e29b0bd6b281370f9c9c8e10701a0
2 parents 551862c + a7d37a9 commit f15435d

File tree

1 file changed

+40
-8
lines changed

1 file changed

+40
-8
lines changed

lib/SIL/LinearLifetimeChecker.cpp

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ struct State {
6363
/// put in missing destroys.
6464
SmallVectorImpl<SILBasicBlock *> *leakingBlocks;
6565

66+
/// The list of passed in consuming uses.
67+
ArrayRef<BranchPropagatedUser> consumingUses;
68+
69+
/// The list of passed in non consuming uses.
70+
ArrayRef<BranchPropagatedUser> nonConsumingUses;
71+
6672
/// The set of blocks with consuming uses.
6773
SmallPtrSet<SILBasicBlock *, 8> blocksWithConsumingUses;
6874

@@ -80,16 +86,22 @@ struct State {
8086

8187
State(SILValue value, SmallPtrSetImpl<SILBasicBlock *> &visitedBlocks,
8288
ErrorBehaviorKind errorBehavior,
83-
SmallVectorImpl<SILBasicBlock *> *leakingBlocks)
89+
SmallVectorImpl<SILBasicBlock *> *leakingBlocks,
90+
ArrayRef<BranchPropagatedUser> consumingUses,
91+
ArrayRef<BranchPropagatedUser> nonConsumingUses)
8492
: value(value), beginBlock(value->getParentBlock()), error(errorBehavior),
85-
visitedBlocks(visitedBlocks), leakingBlocks(leakingBlocks) {}
93+
visitedBlocks(visitedBlocks), leakingBlocks(leakingBlocks),
94+
consumingUses(consumingUses), nonConsumingUses(nonConsumingUses) {}
8695

8796
State(SILBasicBlock *beginBlock,
8897
SmallPtrSetImpl<SILBasicBlock *> &visitedBlocks,
8998
ErrorBehaviorKind errorBehavior,
90-
SmallVectorImpl<SILBasicBlock *> *leakingBlocks)
99+
SmallVectorImpl<SILBasicBlock *> *leakingBlocks,
100+
ArrayRef<BranchPropagatedUser> consumingUses,
101+
ArrayRef<BranchPropagatedUser> nonConsumingUses)
91102
: value(), beginBlock(beginBlock), error(errorBehavior),
92-
visitedBlocks(visitedBlocks), leakingBlocks(leakingBlocks) {}
103+
visitedBlocks(visitedBlocks), leakingBlocks(leakingBlocks),
104+
consumingUses(consumingUses), nonConsumingUses(nonConsumingUses) {}
93105

94106
void initializeAllNonConsumingUses(
95107
ArrayRef<BranchPropagatedUser> nonConsumingUsers);
@@ -124,6 +136,22 @@ struct State {
124136
/// for validity. If this is a linear typed value, return true. Return false
125137
/// otherwise.
126138
void checkDataflowEndState(DeadEndBlocks &deBlocks);
139+
140+
void dumpConsumingUsers() const {
141+
llvm::errs() << "Consuming Users:\n";
142+
for (auto user : consumingUses) {
143+
llvm::errs() << *user.getInst();
144+
}
145+
llvm::errs() << "\n";
146+
}
147+
148+
void dumpNonConsumingUsers() const {
149+
llvm::errs() << "Non Consuming Users:\n";
150+
for (auto user : nonConsumingUses) {
151+
llvm::errs() << *user.getInst();
152+
}
153+
llvm::errs() << "\n";
154+
}
127155
};
128156

129157
} // end anonymous namespace
@@ -224,7 +252,8 @@ void State::initializeConsumingUse(BranchPropagatedUser consumingUser,
224252
llvm::errs() << "Value: N/A\n";
225253
}
226254
llvm::errs() << "User: " << *consumingUser << "Block: bb"
227-
<< userBlock->getDebugID() << "\n\n";
255+
<< userBlock->getDebugID() << "\n";
256+
dumpConsumingUsers();
228257
});
229258
}
230259

@@ -327,7 +356,8 @@ void State::checkPredsForDoubleConsume(BranchPropagatedUser consumingUser,
327356
}
328357

329358
llvm::errs() << "User: " << *consumingUser << "Block: bb"
330-
<< userBlock->getDebugID() << "\n\n";
359+
<< userBlock->getDebugID() << "\n";
360+
dumpConsumingUsers();
331361
});
332362
}
333363

@@ -356,7 +386,8 @@ void State::checkPredsForDoubleConsume(SILBasicBlock *userBlock) {
356386
llvm::errs() << "N/A. \n";
357387
}
358388

359-
llvm::errs() << "Block: bb" << userBlock->getDebugID() << "\n\n";
389+
llvm::errs() << "Block: bb" << userBlock->getDebugID() << "\n";
390+
dumpConsumingUsers();
360391
});
361392
}
362393

@@ -514,7 +545,8 @@ LinearLifetimeError LinearLifetimeChecker::checkValue(
514545
SmallVectorImpl<SILBasicBlock *> *leakingBlocks) {
515546
assert(!consumingUses.empty() && "Must have at least one consuming user?!");
516547

517-
State state(value, visitedBlocks, errorBehavior, leakingBlocks);
548+
State state(value, visitedBlocks, errorBehavior, leakingBlocks, consumingUses,
549+
nonConsumingUses);
518550

519551
// First add our non-consuming uses and their blocks to the
520552
// blocksWithNonConsumingUses map. While we do this, if we have multiple uses

0 commit comments

Comments
 (0)